Skip to content

fix(android): Add multi-activity awareness to ReactHostImpl.onHostDestroy#161

Merged
joemun merged 1 commit into0.81.4-discordfrom
joemun/react-host-multi-activity-destroy
Apr 14, 2026
Merged

fix(android): Add multi-activity awareness to ReactHostImpl.onHostDestroy#161
joemun merged 1 commit into0.81.4-discordfrom
joemun/react-host-multi-activity-destroy

Conversation

@joemun
Copy link
Copy Markdown

@joemun joemun commented Apr 14, 2026

Based on this previous fix: e09d4e8

onHostPause checks activeActivities and skips pausing when other activities are still active. onHostDestroy lacked this check, so destroying a secondary activity while the primary was still alive would move the shared ReactContext to BEFORE_CREATE:

private fun moveToHostDestroy(currentContext: ReactContext?) {
reactLifecycleStateManager.moveToOnHostDestroy(currentContext)
currentActivity = null
}

fun moveToOnHostDestroy(currentContext: ReactContext?) {
currentContext?.let {
when (state) {
LifecycleState.BEFORE_RESUME -> {
bridgelessReactStateTracker.enterState("ReactContext.onHostDestroy()")
it.onHostDestroy()
}
LifecycleState.RESUMED -> {
bridgelessReactStateTracker.enterState("ReactContext.onHostPause()")
it.onHostPause()
bridgelessReactStateTracker.enterState("ReactContext.onHostDestroy()")
it.onHostDestroy()
}
else -> {
/* Do nothing */
}
}
}
state = LifecycleState.BEFORE_CREATE
}

If the primary activity was never paused, no subsequent onHostResume would fire, leaving the context permanently destroyed and unresponsive to input.

onHostPause already checks activeActivities and skips pausing when
other activities are still active. onHostDestroy lacked this check,
so destroying a secondary activity while the primary was still alive
would move the shared ReactContext to BEFORE_CREATE. If the primary
was never paused, no subsequent onHostResume would fire, leaving the
context permanently destroyed and unresponsive to input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joemun joemun requested review from Flewp and tpcstld April 14, 2026 15:44
@joemun joemun changed the title [fix] Add multi-activity awareness to ReactHostImpl.onHostDestroy [Discord] Add multi-activity awareness to ReactHostImpl.onHostDestroy Apr 14, 2026
@joemun joemun changed the title [Discord] Add multi-activity awareness to ReactHostImpl.onHostDestroy fix(android): Add multi-activity awareness to ReactHostImpl.onHostDestroy Apr 14, 2026
@joemun joemun merged commit 4b1db74 into 0.81.4-discord Apr 14, 2026
54 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant