Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix NPE when navigating away from a screen with RiveUI#406

Open
EricKuck wants to merge 1 commit intorive-app:master from
EricKuck:master
Open

Fix NPE when navigating away from a screen with RiveUI #406
EricKuck wants to merge 1 commit intorive-app:master from
EricKuck:master

Conversation

@EricKuck
Copy link

@EricKuck EricKuck commented Sep 9, 2025

When navigating away from a screen with the RiveUI composable, there's a race condition that can lead to an NPE (stacktrace follows). The issue is that the RiveSurface is nulled out in one callback, while it's asserted to be non-null within a while loop in a coroutine. It is non-deterministic which will be called first, so we have to check whether or not surface is null rather than forcing it to be treated as non-null.

java.lang.NullPointerException
	at app.rive.RiveUIKt$RiveUI7ドル2ドル.invokeSuspend(RiveUI.kt:264)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:79)
	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback1ドル.run(AndroidUiDispatcher.android.kt:57)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /