Skip to content

fix: preserve Android images with bounded lifecycle - #91

Open
huhuanming wants to merge 6 commits into
mainfrom
codex/fix-image-modal-lifecycle-3.0.102
Open

fix: preserve Android images with bounded lifecycle#91
huhuanming wants to merge 6 commits into
mainfrom
codex/fix-image-modal-lifecycle-3.0.102

Conversation

@huhuanming

@huhuanming huhuanming commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • scope Android OneKeyImage rendering requests to the host FragmentActivity, above temporary ScreenStack Fragment teardown but below the application lifetime
  • reset lifecycle-cleared image requests so an exceptional view reattachment can recover without reloading during normal task modal transitions
  • load the Android background runtime reusable DevSession common HBC from a restored file path, with the packaged asset path retained as fallback
  • bump all 37 publishable packages to 3.0.104 and document the release in CHANGELOG.md

Root causes

  • Glide.with(hostView) scoped image requests to the ScreenStack Fragment removed by opaque task modals, so retained React image views lost their drawables.
  • The temporary application-scoped workaround preserved images but did not pause requests when the Activity stopped or release them when it was destroyed.
  • BackgroundThread treated the reusable DevSession common HBC location as an APK asset name even when the shell restored it as a local file.

Verification

  • yarn workspace @onekeyfe/react-native-image typecheck
  • yarn workspace @onekeyfe/react-native-image lint
  • yarn workspace @onekeyfe/react-native-image test --runInBand
  • Android :onekeyfe_react-native-image:compileDebugKotlin
  • Android :onekeyfe_react-native-image:testDebugUnitTest
  • yarn workspace @onekeyfe/react-native-image prepare
  • npm pack --dry-run --json
  • yarn workspace @onekeyfe/react-native-background-thread typecheck
  • yarn workspace @onekeyfe/react-native-background-thread lint
  • yarn workspace @onekeyfe/react-native-background-thread test --runInBand
  • Android :onekeyfe_react-native-background-thread:compileDebugKotlin
  • yarn install --immutable
  • node scripts/validate-npm-dist-tag.mjs latest
  • verified all 37 publishable package versions are 3.0.104

Release note

3.0.104 supersedes the application-scoped Android image workaround from 3.0.102 and includes the background-thread DevSession file loading fix first released in 3.0.103.

Platform scope

  • Image fix: Android main UI runtime; Glide is process-owned and the background JS runtime is unaffected.
  • Dev-vendor fix: Android background JS runtime; main and background have isolated JS heaps while the restored HBC file is process-accessible.

@huhuanming huhuanming changed the title fix: preserve Android images across task modals fix: preserve Android images and load restored dev vendor Sep 4, 2026
@huhuanming huhuanming changed the title fix: preserve Android images and load restored dev vendor fix: preserve Android images with bounded lifecycle Sep 4, 2026
private val requestManager by lazy(LazyThreadSafetyMode.NONE) {
val activity = context.findFragmentActivity()
?: (context.currentActivity as? FragmentActivity)
Glide.with(requireNotNull(activity) { "A FragmentActivity is required to load images" })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: [Default ReactActivity hosts cannot initialize the image request manager]

When this package runs in a standard React Native host such as the repository example's MainActivity : ReactActivity(), that Activity is not a FragmentActivity. Both lookups therefore return null, and requireNotNull throws when the first image request accesses requestManager, so the component crashes instead of loading the image.

Please unwrap or read the host as android.app.Activity and pass that Activity to Glide's Activity overload. This preserves Activity-scoped cleanup without excluding standard React Native hosts.

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.

2 participants