Android14 with Samsung Fold Device. UnsupportedOperationException: Tried to obtain display from a Context not associated with one
Asked Answered
O

2

6

I'm getting UnsupportedOperationException crash on live app. All the crashes are associated with Samsung Fold Android 14 devices. But still no clue how to reproduce or fix this. Any help would be appreciated.

Fatal Exception: java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.
       at android.app.ContextImpl.getDisplay(ContextImpl.java:3166)
       at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1209)
       at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1209)
       at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1209)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.shouldReportDisplayFeatures(WindowLayoutComponentImpl.java:355)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.getDisplayFeatures(WindowLayoutComponentImpl.java:313)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.getWindowLayoutInfo(WindowLayoutComponentImpl.java:265)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.onDisplayFeaturesChanged(WindowLayoutComponentImpl.java:250)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.$r8$lambda$CcdqSJgN0v7j8yjFplaR5_gC_ag()
       at androidx.window.extensions.layout.WindowLayoutComponentImpl$ExternalSyntheticLambda0.accept(:4)
       at androidx.window.util.BaseDataProducer.notifyDataChanged(BaseDataProducer.java:101)
       at androidx.window.common.DeviceStateManagerFoldingFeatureProducer.notifyFoldingFeatureChange(DeviceStateManagerFoldingFeatureProducer.java:212)
       at androidx.window.common.DeviceStateManagerFoldingFeatureProducer.-$Nest$mnotifyFoldingFeatureChange()
       at androidx.window.common.DeviceStateManagerFoldingFeatureProducer\$1.$r8$lambda$Cq8m54r9pahGe0xgKiimh_L76YM()
       at androidx.window.common.DeviceStateManagerFoldingFeatureProducer\$1$ExternalSyntheticLambda0.accept(:4)
       at androidx.window.common.RawFoldingFeatureProducer.getData(RawFoldingFeatureProducer.java:71)
       at androidx.window.common.DeviceStateManagerFoldingFeatureProducer\$1.onStateChanged(DeviceStateManagerFoldingFeatureProducer.java:87)
       at android.hardware.devicestate.DeviceStateManagerGlobal$DeviceStateCallbackWrapper.lambda$notifyStateChanged\$2(DeviceStateManagerGlobal.java:428)
       at android.hardware.devicestate.DeviceStateManagerGlobal$DeviceStateCallbackWrapper.$r8$lambda$FiFeo7UDl_Jzgv3ijVmtwGDn8K0()
       at android.hardware.devicestate.DeviceStateManagerGlobal$DeviceStateCallbackWrapper$ExternalSyntheticLambda0.run(:4)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Overboard answered 3/6 at 6:39 Comment(6)
Any update? we met the same problem. Mainly occur in Galaxy fold.Spiculum
Me too, Samsung Galaxy Z Fold4. It seems it's bug in some AndroidX library.Nowlin
There are several reports: issuetracker#344735119, issuetracker#344912774 and Samsung Developer Forum. No known solution yet, but everybody write about issue in system code.Nowlin
@Nowlin any luck?Starofbethlehem
@Overboard any luck fixing?Deferred
We are also seeing this crash in our app, and found out that the webview is internally probably subscribing for window classification changes with the passed context and if you change that context later at some point such that it is not a UI context will crash the appRovelli
D
0

This crash must be fixed with WebView update to version 127.0.6486.0 and up (expected stable release Tue, Jul 23, 2024 https://chromiumdash.appspot.com/schedule ). Chromium issue tracker -> https://issues.chromium.org/issues/351582214

EDIT: Confirmed - WebView update solved the problem

Deferred answered 16/7 at 6:43 Comment(0)
S
0

Our new app version has completely eliminated this problem. which was solved by calling Webview.destroy().

Others can also solve this problem by waiting for the new webview to be released (late july).

https://issues.chromium.org/issues/351582214 https://chromium-review.googlesource.com/c/chromium/src/+/5548161

Spiculum answered 19/7 at 1:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.