Repository navigation
fix(mobile): sharing into the Android app after it was killed in the background no longer drops the share - #47252
Conversation
…background no longer drops the share MainActivity is singleTask, so when Android has killed the process but kept the task, it recreates the activity and delivers the share to onNewIntent. In release builds that arrives while expo-updates still holds startup, and Expo's activity wrapper discards intents in that window, so expo-sharing never sees the share. expo-sharing now also listens on ComponentActivity, which still receives it.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Restores Android share delivery after background process death by capturing intents during delayed startup. The change retains the existing share-intent filter and routes content through the existing draft workflow. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Problem
On Android, sharing an image into T3 Code after the system killed the app in the background does nothing. The app opens to the thread list and the image is gone. Sharing again while the app is open works, so the workaround is to share twice.
To reproduce on a release build: open T3 Code, go home, kill its process (
adb shell am kill com.t3tools.t3code, which is what Android does to background apps under memory pressure), then share a photo from Files or Photos.Change
MainActivityissingleTask. When the task is still in recents but its process is dead, Android starts a new process, recreates the activity from its old launcher intent, and delivers the share toonNewIntent. In release builds, expo-updates holds startup while it picks the bundle, and Expo'sReactActivityDelegateWrapper.onNewIntentreturns early until loading is ready. It drops the intent without calling any lifecycle listener, so expo-sharing never stores the share and the inbox reads nothing. A warm share arrives after loading is ready, which is why the second attempt works.When the wrapper returns early,
ReactActivityfalls through toComponentActivity.onNewIntent, and the AndroidX new-intent listeners still see the intent. The existing expo-sharing patch now registers one of those listeners in itsonCreate, which Expo always runs, and stores share intents the same way its ownonNewIntentdoes. On a warm share both paths store the same intent.I first patched Expo's wrapper to queue
onNewIntentbehind startup, like it already does foronResumeandonPause. Patchingexpoitself puts an=in the pnpm store path of theexpo-modules-coreit resolves, and prefab rejects that path, so the Android build fails. Expo's main branch still drops the intent.Scope
A small fix for a bug that loses user input. No issue filed.
Verification
Release builds (x86_64,
assembleRelease) on an Android 16 emulator, paired to a local dev server, sharing a PNG from the Files app:Start procandSTART ... LAUNCH_SINGLE_TASK ... result code=2(delivered to the existing task). The app opened to the thread list with no share.result code=2, and the project picker opened for the image both times.The two APKs differed only in this patch. Not checked: a physical device, and iOS (unchanged, the patch is Android-only).
Claude Opus 5.5, Claude Code in T3 Code. Root cause traced with GPT-6.2 Astra, reviewed by GPT-6.2 Sol.