Opened 3 months ago

Closed 4 weeks ago

#15374 closed defect (wontfix)

ANDROID: Log Debug level is reset when force closing the app

Reported by: antoniou79 Owned by: lephilousophe
Priority: normal Component: Port: Android
Version: Keywords:
Cc: Game:

Description

This was mentioned on Discord (android-support channel) and it affects ScummVM 2.8.1.1 and 2.9.0git, probably older versions too.

If the user sets the Debug level to something other than None (From Global Options -> Misc -> Debug level), eg. "4", then press Apply and Ok (or just Ok), and then force close ScummVM from the "recent apps" system view of the Android OS, then upon relaunching ScummVM the Debug level will be reset to None.

This happens consistently with the above steps. It also does not matter if ScummVM is at the launcher screen or running some game when it's forced closed. The bug will occur either way.

However, the bug will not happen if the user exits the game or ScummVM properly (ie. from Launcher using "Quit" and from within the game using GMM's Quit or Return to Launcher and then Quit).

I have not tested as of yet, if there are cases of games where using their native Quit menu option would result in this bug too.

Note: This bug was brought up as something that was noticed while trying to trigger a more serious bug, whereby the games list would be wiped upon launching ScummVM (presumably due to the ScummVM configuration file being reset). It's very likely the later more serious bug is also connected to force closing the ScummVM app, albeit it's not as consistently reproducible. The user reporting the issue was on an Android 14, running ScummVM 2.8.1.1.

Change History (4)

comment:1 by antoniou79, 3 months ago

This issue, and the more serious one of wiping the configuration file, may be have the same root cause with an similar issue reported for iOS here: https://bugs.scummvm.org/ticket/14623

comment:2 by antoniou79, 3 months ago

With respect to the specific issue of this ticket (loss of Debug level setting), it looks like the intended behavior is actually that the Debug level is not saved in the ScummVM configuration file.

For example on Windows (tested with a 2.9.0git build from latest master HEAD) no corresponding key-value is written to scummvm.ini after applying the change via the Launcher GUI nor after exiting ScummVM, and the value is reset to "None" upon relaunch. This is also confirmed by looking at our source code and how gDebugLevel is initialized/updated but never stored to ConfMan (although there's some (maybe remnant) code that checks for ConfMan's "debuglevel" here: https://github.com/scummvm/scummvm/blob/d7a6701a66c66578539c4010f3ca9df1bd40d5f5/base/main.cpp#L475

I've still have not investigated thoroughly why Android specifically keeps the set value if the user quits ScummVM properly (via Quit from the launcher). I can confirm though that the scummvm.ini file on Android remains unchanged (no key-value is added nor updated) when applying the debug level change from the GUI or when subsequently quitting ScummVM.

Maybe the gDebugLevel is cached by the Android System because its a variable with global scope?
See: https://github.com/scummvm/scummvm/blob/d7a6701a66c66578539c4010f3ca9df1bd40d5f5/common/debug.h#L149
and: https://github.com/scummvm/scummvm/blob/d7a6701a66c66578539c4010f3ca9df1bd40d5f5/common/debug.cpp#L31

Also might be relevant: For a brief period and specific debug purposes, we used to explicitly override and set the gDebugLevel in the android.cpp's initBackend() as shown by this commit change:
https://github.com/scummvm/scummvm/commit/67743660cac#diff-d112ba6d5371b6b878f86ddd82035bd646f53e85e0a2cc5164233b36f009c11d

comment:3 by lephilousophe, 5 weeks ago

The gDebugLevel variable is a global variable.
The libscummvm.so library is loaded when ScummVM class is initialized but it is never unloaded as this is not really possible in Java.
When we press the quit button, the native thread is shut and the activity closed but the process (with libscummvm.so loaded) is kept alive for future launches.
Hence, the gDebugLevel variable keeps its value.

comment:4 by lephilousophe, 4 weeks ago

Owner: set to lephilousophe
Resolution: wontfix
Status: newclosed

A note about the way of work has been added to the Wiki.
Closing this.

Note: See TracTickets for help on using tickets.