[RFC] Android 12: display manager init failed with external HDMI
At Baylibre we do the support of Android on Mediatek boards.
Example: https://www.mediatek.com/products/AIoT/i500
Our setup is simple, mediatek board with HDMI connector (no internal display).
We are switching from Android 11 to Android 12 and we see an issue with the display manager.
D AndroidRuntime: Shutting down VM
E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
E AndroidRuntime: java.lang.RuntimeException: Failed to boot service com.android.server.display.DisplayManagerService: onBootPhase threw an exception during phase 100
E AndroidRuntime: at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:238)
E AndroidRuntime: at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:1133)
E AndroidRuntime: at com.android.server.SystemServer.run(SystemServer.java:877)
E AndroidRuntime: at com.android.server.SystemServer.main(SystemServer.java:610)
E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
E AndroidRuntime: Caused by: java.lang.RuntimeException: Timeout waiting for default display to be initialized. DefaultDisplay=null, mVirtualDisplayAdapter=com.android.server.display.VirtualDisplayAdapter@2ea9637
E AndroidRuntime: at com.android.server.display.DisplayManagerService.onBootPhase(DisplayManagerService.java:506)
E AndroidRuntime: at com.android.server.SystemServiceManager.startBootPhase(SystemServiceManager.java:235)
E AndroidRuntime: ... 6 more
E AndroidRuntime: Error reporting crash
E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.IActivityManager.handleApplicationCrash(android.os.IBinder, android.app.ApplicationErrorReport$ParcelableCrashInfo)' on a null object reference
E AndroidRuntime: at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:156)
E AndroidRuntime: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
E AndroidRuntime: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
E AndroidRuntime: at java.lang.Thread.dispatchUncaughtException(Thread.java:2200)
From our investigation, we see that some logics have been changed in the display manager.
On Android 11:
addLogicalDisplayLocked
checked the flag FLAG_DEFAULT_DISPLAY from DisplayDeviceInfo and assigned the display Id of our HDMI as DEFAULT_DISPLAY.
-> no issue, during onBootPhase, getDisplayLocked(Display.DEFAULT_DISPLAY) != NULL
On Android 12:
The flag FLAG_DEFAULT_DISPLAY is not checked anymore and by default the display Id of our HDMI is now set to 1.
Since our display is an External type, we don't call initializeInternalDisplayDeviceLocked
and no display Id is assigned as DEFAULT_DISPLAY.
Thus we hit the fatal exception above.
As workaround for now in drm_hwcomposer we return the HDMIA connector as Internal.
That fix our issue, but that is not clean at all ...
We wanted to share with you this issue because you may have seen this fail and have some thoughts about that.
For us it's not clear where the fix need to be done, drm_hwcomposer or display manager ?
Please do not hesitate to ask me more logs or do some tests.
I'll be glad to help on the subject.
Thanks