Search code examples
androidc++qtandroid-emulatorqml

Qt Quick Android application shows blank screen if it is started more than 1 time


I've got problems with applications based on Qt Quick - they don't work properly on Android emulators with API > 24 (newer than Android 7.0).

Building and deploying are finished OK. But the application works only for the first time - if I quit an application (tap "back" or "home" or close the application) and open it again, only blank screen is appeared. This problems stays until I reinstall the app or clear app cache.


Gif with problem representing:

enter image description here

There's no that problem on real phones. Projects built in Android Studio don't have such problems as well.

Application based on Qt Widgets works correctly without blank screens.

The only suspicious thing I got from logcat is that (it logged after the second start of application):

06-04 10:06:24.976  1899  1989 W InputDispatcher: channel 'c7fea10 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
06-04 10:06:24.977  1899  1989 E InputDispatcher: channel 'c7fea10 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-04 10:06:24.977  1756  1756 I Zygote  : Process 4511 exited cleanly (0)
06-04 10:06:24.977  1899  2568 I WindowManager: WIN DEATH: Window{c7fea10 u0 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity}
06-04 10:06:24.977  1899  2568 W InputDispatcher: Attempted to unregister already unregistered input channel 'c7fea10 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity (server)'
06-04 10:06:24.977  1899  3872 I ActivityManager: Process org.qtproject.example.testandroidqml (pid 4511) has died: cch  CRE 
06-04 10:06:24.977  1899  1917 W libprocessgroup: kill(-4511, 9) failed: No such process
06-04 10:06:24.977  1899  1917 I libprocessgroup: Successfully killed process cgroup uid 10086 pid 4511 in 0ms
06-04 10:06:24.978  1755  2486 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{86cbd61 token=Token{a4f68c8 ActivityRecord{b83956b u0 org.qtproject.example.testandroidqml/org.qtproject.qt5.android.bindings.QtActivity t12}}}#0
06-04 10:06:24.979  1899  1922 W ActivityManager: setHasOverlayUi called on unknown pid: 4511
06-04 10:06:24.979  1755  1755 W SurfaceFlinger: couldn't log to binary event log: overflow.

Why does it happen and how can I solve this issue?

My conditions:

  • Ubuntu 22.04
  • Project is simple - default one created with Qt Creator + red rectangle in main.qml added. It is built under Qt 5.15 with CMake
  • Emulator "Pixel XL" under API 28 (Android 9.0) from Android Studio

I tried:

  • different emulators and different APIs (it doesn't work anywhere except Android 7.0)
  • deploying with Qt Creator and manual apk installations - doesn't affect anything

Solution

  • It seems like I have found the solution.

    The problem is solved when I set the value "Software" instead of "Automatic" for the option "Graphics" in the emulator perfomance settings (Android Studio's device manager).

    enter image description here

    Or you can set it manually in the emulator config file by changing hw.gpu.mode property value to software.

    It works slower now but at least it works!