Skip to content

fix(mobile): sharing into the Android app after it was killed in the background no longer drops the share - #47252

Merged
Yash-Singh1 merged 1 commit into
pingdotgg:mainfrom
SunkenInTime:fix/android-share-cold-start
Dec 3, 2026
Merged

Yash-Singh1 merged 1 commit into
pingdotgg:mainfrom
SunkenInTime:fix/android-share-cold-start

Conversation

@SunkenInTime

Copy link
Copy Markdown
Contributor

Before and after: sharing an image into T3 Code after Android killed it in the background

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

MainActivity is singleTask. 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 to onNewIntent. In release builds, expo-updates holds startup while it picks the bundle, and Expo's ReactActivityDelegateWrapper.onNewIntent returns 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, ReactActivity falls through to ComponentActivity.onNewIntent, and the AndroidX new-intent listeners still see the intent. The existing expo-sharing patch now registers one of those listeners in its onCreate, which Expo always runs, and stores share intents the same way its own onNewIntent does. On a warm share both paths store the same intent.

I first patched Expo's wrapper to queue onNewIntent behind startup, like it already does for onResume and onPause. Patching expo itself puts an = in the pnpm store path of the expo-modules-core it 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:

  • Base build, process killed: Android logged Start proc and START ... LAUNCH_SINGLE_TASK ... result code=2 (delivered to the existing task). The app opened to the thread list with no share.
  • Base build, sharing again while running: the project picker opened for the image.
  • This branch, same cold steps, twice: Android logged the same fresh process and 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.

…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.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. 📱 Native Change Changes the native fingerprint; merging blocks production OTAs until a new store build ships. size:S 10-29 changed lines (additions + deletions). labels Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at cfef186

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.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Expo sharing patch updates Android share-intent handling and payload parsing, adds optional nullable originalName to SharePayload, and changes how iOS project generation adds an Info.plist reference.

Changes: Expo sharing updates

Layer / File(s) Summary
Platform share handling and payload updates
patches/[email protected]
Android handles share intents received through onNewIntent, applies MIME and text rules, and includes nonblank resolver display names as originalName. The SharePayload type adds optional nullable originalName. iOS project generation adds a separate Info.plist reference.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to cfef1 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a fix so Android shares into the app after the app was killed in the background are no longer dropped. The raw summary shows the patch stores share intents received th…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the cold-share bug and reproduction steps. The Change section explains the sin…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a fix so Android shares into the app after the app was killed in the background are no longer dropped. The raw summary shows the patch stores share intents received through onNewIntent and registers a new-intent listener in onCreate, which matches the title. The title is 105 characters, which is longer than ideal, but it stays specific and readable.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the cold-share bug and reproduction steps. The Change section explains the singleTask activity, the Expo wrapper that drops onNewIntent during startup, and why the patch registers an AndroidX listener. The Scope section says it is a small fix for a bug that loses input and that no issue was filed. The Verification section lists release-build tests on an Android 16 emulator, with observed log results and the untested items (physical device, iOS). The template's model/harness line is also present. The description does not include a before/after screenshot in the body, but it does embed one at the top, and the UI change is covered by the screenshot. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 76c8661 and cfef186.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 1

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@Yash-Singh1
Yash-Singh1 merged commit 7c34669 into pingdotgg:main Dec 3, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📱 Native Change Changes the native fingerprint; merging blocks production OTAs until a new store build ships. size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants