Herdinger / EmulationStation

A flexible emulator front-end supporting keyboardless navigation and custom system themes.
MIT License
68 stars 7 forks source link

Problem for quitting EmulationStation #6

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi,

With Ubuntu 16.04, when quitting EmulationStation, the window is closed, but ES is still in memory, using a lot of ressources, and it must be kill.

Herdinger commented 8 years ago

Could you post the es-log.txt file in your configuration directory?

ghost commented 8 years ago

Here it is :

lvl2: EmulationStation - v2.0.1a, built Mar 3 2016 - 16:33:25 lvl2: Creating surface... lvl2: Created window successfully. lvl2: Added known joystick USB,2-axis 8-button gamepad (instance ID: 0, device index: 0) lvl2: Checking available OpenGL extensions... lvl2: ARB_texture_non_power_of_two: ok lvl2: Loading system config file /home/marc/.config/emulationstation/es_systems.cfg... lvl2: Parsing XML file "/home/marc/.config/emulationstation/gamelists/mastersystem/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Megadrive/Sega 32x/gamelist.xml"... lvl2: Parsing XML file "/home/marc/.config/emulationstation/gamelists/gb/gamelist.xml"... lvl2: Parsing XML file "/home/marc/.config/emulationstation/gamelists/snes/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Megadrive/ROMS/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Atari 2600/gamelist.xml"... lvl2: Parsing XML file "/home/marc/.config/emulationstation/gamelists/nes/gamelist.xml"... lvl2: Parsing XML file "/home/marc/.config/emulationstation/gamelists/gba/gamelist.xml"... lvl2: Parsing XML file "/home/marc/.config/emulationstation/gamelists/n64/gamelist.xml"... lvl2: req sound [detailed.back] lvl2: (missing) lvl2: req sound [detailed.back] lvl2: (missing)

wolf-sigma commented 8 years ago

Do you mind running with the --debug flag and posting the log for that too?

Hancharenko commented 8 years ago

The same thing happens on Windows. Whether you exit through the EmulationStation menus or Alt+F4, the process is still running with quite a bit of resources still in use.

~25MB of RAM and about 40% CPU time on a dual-core Celeron 2957U.

wolf-sigma commented 8 years ago

Hey @Hancharenko - could you also provide an output of a log with a --debug as a parameter?

Hancharenko commented 8 years ago

Fresh from the console. Interestingly, when emulationstation.exe --debug is executed, the process terminates properly once the command prompt generated by the debug flag is closed. I also analyzed the wait chain and noticed that emulationstation.exe appears to be waiting for the process "dwm.exe" (Microsoft's Desktop Window Manager).

ConfigPath C:/Users/mickey/Documents/EmulationStation
lvl2:   EmulationStation - v2.0.1a, built Apr  5 2016 - 19:09:22
lvl2:   Creating surface...
lvl2:   Created window successfully.
lvl2:   Checking available OpenGL extensions...
lvl2:    ARB_texture_non_power_of_two: ok
lvl2:   Loading system config file C:/Users/mickey/Documents/EmulationStation/es_systems.cfg...
lvl1:     Unknown platform for system "windows" (platform "windows" from list "windows")
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/windows/gamelist.xml"...
lvl1:     Unknown platform for system "virtualboy" (platform "virtualboy" from list "virtualboy")
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/virtualboy/gamelist.xml"...
lvl1:     Unknown platform for system "vectrex" (platform "vectrex" from list "vectrex")
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/vectrex/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/wonderswan/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/atarijaguar/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/atarilynx/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/atari7800/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/atari2600/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/ngp/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/ngpc/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/gbc/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/gb/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/gba/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/gamegear/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/dreamcast/gamelist.xml"...
lvl1:     Unknown platform for system "mame" (platform "mame" from list "mame")
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/mame/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/msx/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/nes/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/n64/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/pcengine/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/mastersystem/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/genesis/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/segacd/gamelist.xml"...
lvl1:   System "segacd" has no games! Ignoring it.
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/sega32x/gamelist.xml"...
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/psx/gamelist.xml"...
lvl1:   System "psx" has no games! Ignoring it.
lvl2:   Parsing XML file "C:/Users/mickey/Documents/EmulationStation/gamelists/snes/gamelist.xml"...
ghost commented 8 years ago

When I close ES, the terminal is blocked on the last line. When I close the terminal, then ES is closed.

ConfigPath /home/marc/.config/emulationstation lvl2: EmulationStation - v2.0.1a, built Apr 3 2016 - 09:41:44 lvl2: Creating surface... lvl2: Created window successfully. lvl2: Added known joystick USB,2-axis 8-button gamepad (instance ID: 0, device index: 0) lvl2: Checking available OpenGL extensions... lvl2: ARB_texture_non_power_of_two: ok lvl2: Loading system config file /home/marc/.config/emulationstation/es_systems.cfg... lvl2: Parsing XML file "/media/marc/Jeux/Sega Master System/ROMS/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Megadrive/Sega 32x/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Game Boy & Game Boy Color/Game Boy/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Nintendo Super Nes/SNES Roms/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Megadrive/ROMS/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Nintendo 64/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Atari 2600/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Game Boy Advance/Roms/gamelist.xml"... lvl2: Parsing XML file "/media/marc/Jeux/Nintendo Nes/gamelist.xml"...

wolf-sigma commented 8 years ago

Did some debugging last night and made a couple observations:

I'll have to dig further to see why it's doing this.

Hancharenko commented 8 years ago

Thanks for looking into this. It does it every time on the one box I'm building. I could throw it on another couple of workstations later this week and see if I encounter the same issue. I've had multiple instances of EmulationStation sitting with processes running, so it is probably safe to say that if they are terminating, it takes a LONG time for them to do so (possibly a few hours as you indicated you were seeing)

wolf-sigma commented 8 years ago

I did more debugging, and there seemed to be a correlation to the number of files in the XML library per system and the time it took to run through the updateGamelist(this); function on line 61 of SystemData.cpp. It seems to take an exponential amount of time which is weird. For instance, one system of mine was 6000 files, and it took ~10 min while a 700 took less than a min.

We now know where the issue is, but we need to figure out what's causing this.

dankcushions commented 8 years ago

yes this is just saving all the xml files. I believe it rebuilds them all. it takes exponentially longer amount of time the more Roms you have.

an sql database may solve/improve this. I believe there's already a PR

Herdinger commented 8 years ago

Sorry for being so in active, life got really busy. I just took a quick look at this and the problem seems to lay in the fact that the algorithm is quadratic with a bunch of string comparisons as a constant factor. The most baffling thing to me is, that this convoluted procedure seems entirely unnecessary, there is no way gamelist.xml is going to get modified without FileData from a running EmulationStation process.

Is the scraping experience also unbearably slow for you? I'm going to work on a fix for today or tomorrow.

Hancharenko commented 8 years ago

I've been using an external scraper due to the large number of inaccurate matches....but yes, the built-in scraper is painfully slow.

I was also able to verify that the larger (and more numerous) the gamelist.xml files, the longer it takes to exit the process. The time varies based on processor per-clock performance as well.