Skip to content

Crash in fun onConfigurationChanged() #4358

Open
@Jeff11

Description

@Jeff11

Integration

sentry-android

Build System

Gradle

AGP Version

8.9.2

Proguard

Disabled

Version

8.9.0

Steps to Reproduce

App runs on tablet in landscape, an activity with forced portrait is started, then exception is thrown.
Android 15, Tablet emulator.

In MainApp:

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig) // <---- exception here
    // ...
}

Expected Result

Activity in portrait starts normally.

Actual Result

The exception:

Tried to access visual service WindowManager from a non-visual Context:myapp.MainApp@7f6f0d1 WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen. (Ask Gemini)
java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:myapp.MainApp@7f6f0d1
	at android.app.ContextImpl.getSystemService(ContextImpl.java:2236)
	at android.content.ContextWrapper.getSystemService(ContextWrapper.java:936)
	at io.sentry.android.replay.ScreenshotRecorderConfig$Companion.from(ScreenshotRecorder.kt:288)
	at io.sentry.android.replay.ReplayIntegration.onConfigurationChanged(ReplayIntegration.kt:328)
	at android.content.ComponentCallbacksController.lambda$dispatchConfigurationChanged$0(ComponentCallbacksController.java:91)
	at android.content.ComponentCallbacksController$$ExternalSyntheticLambda2.accept(D8$$SyntheticClass:0)
	at android.content.ComponentCallbacksController.forAllComponentCallbacks(ComponentCallbacksController.java:124)
	at android.content.ComponentCallbacksController.dispatchConfigurationChanged(ComponentCallbacksController.java:91)
	at android.app.Application.onConfigurationChanged(Application.java:279)
	at myapp.MainApp.onConfigurationChanged(MainApp.kt:583)
	at android.app.ConfigurationController.performConfigurationChanged(ConfigurationController.java:261)
	at android.app.ConfigurationController.handleConfigurationChangedInner(ConfigurationController.java:235)
	at android.app.ConfigurationController.handleConfigurationChanged(ConfigurationController.java:154)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4219)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:112)
	at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:174)
	at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:109)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2636)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8705)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Needs Discussion

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions