Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-139270

Android app does not start after Activity was destroyed by the system with active Foreground Service running

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.8.3
    • QPA: Android
    • None
    • Android
    • 2025wk38s2QtforAndroid

      If the Qt Android Activity is destroyed by the system (eg. to automatically free resources) with an active Qt foreground Service running, the next time it is started, it freezes with a black screen on startup.

      This is because the QtNative.m_stateDetails.isStarted flag is restored from the Activity instance state (QtActivityBase.onRestoreInstanceState()).

      The flag is then checked in QtNative.startApplication() whose execution is skipped entirely, resulting in no call to the C++ main() function.

      The bug did not exist in Qt 6.4.3 where the flag existed in QtActivityDelegate and was also restored but was not checked in QtNative.startApplication().

      Note that the bug seems to only happen when an active Service is running, because otherwise the system will just kill the application on shutdown without saving an instance state. It also does not happen when closing the app manually, eg. from the task manager or by quitting Qt from within the application.

      It can be reproduce by setting "do not keep activities" in system developer settings, then starting a Service from the app and putting the app to the background, resulting in the Activity being destroyed and the instance state being saved.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            assam Assam Boudjelthia
            chrisub Christian Bartsch
            Votes:
            7 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes