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

Black screen and crash after going to foreground with events in the queue generated in background



    • Platform/s:
    • Sprint:


      The problem was observed on Android 11 and 12, Android 10 seems to work as expected.

      When the Android app goes to background, the events from the main ui thread's queue are not processed. But some other threads and event loops can still operate, generate events and put them in main ui thread's event loop. Those events should be properly consumed when the app goes back to foreground and main thread is resumed. The attached sample apps reproduce such situation in two different ways.

      The crash happens when some background thread generates events intended to be consumed by the main ui thread. The event handler on the qml side must change the UI state.

      Two scenarios has been tested, in both of them it's easy to end up with crash:

      • events are generated by some c++ worker run in a separate thread, communicating with the qml gui via signals/slots.
      • events are generated using WorkerScript, no C++ code is involved

      The crash was observed when qml handler was modifying gui in a following way:

      • items added to the model used by ListView or GridView
      • items added to the model used by Repeater or Instantiator
      • items are created using Component.createObject() and displayed on the scene

      After going back to foreground for the first time there is a black screen. The second attempt ends up with a segfault.


        1. android_crash.webm
          21.96 MB
        2. CppWorkerExample.zip
          4 kB
        3. WorkerScriptExample-1.zip
          2 kB

          Issue Links

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



              qtandroidteam Qt Android Team
              mcieslak Michał Cieślak
              5 Vote for this issue
              8 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes