Skip to content

fix(android): enable split-screen/multi-window for Samsung devices - #9190

Closed
techinpark wants to merge 1 commit into
stablyai:mainfrom
techinpark:fix/android-split-screen-samsung
Closed

techinpark wants to merge 1 commit into
stablyai:mainfrom
techinpark:fix/android-split-screen-samsung

Conversation

@techinpark

@techinpark techinpark commented Jul 17, 2026 •

Copy link
Copy Markdown

Summary

Adds an Expo config plugin that patches the Android MainActivity manifest entry for multi-window support: it sets android:resizeableActivity="true" and adds smallestScreenSize + density to android:configChanges.

Be aware of what actually does the work here. resizeableActivity is largely a no-op on the SDK this app targets — it defaults to true for targetSdk >= 24 and is ignored entirely on API 31+, and this app is on Expo 55 / RN 0.83. The real fix is the configChanges half: Expo's template omits smallestScreenSize and density, so dragging the split-screen divider destroys and recreates the activity, remounting the React tree and losing UI state. Adding those two keys is what makes split-screen usable rather than merely permitted.

I'd suggest the title undersells it — this is closer to "stop the activity restarting on split-screen resize" than "enable split-screen".

ELI5

On Android you can run two apps side by side and drag the divider to resize them. Orca was being torn down and rebuilt from scratch every time you dragged that divider, so whatever you were looking at got reset. This tells Android "I can handle being resized myself, don't restart me," so dragging the divider just resizes the app smoothly.

The other half of the change — the part the title is about — turns out to have no effect on modern Android, and I've said so rather than claiming credit for it.

Proof of fix

The mobile Vitest suite cannot run in this environment — mobile/tsconfig.json extends expo/tsconfig.base.json, which fails to resolve here (TSConfckParseError). I confirmed this is pre-existing and unrelated to this PR by reproducing it on unmodified main with an existing test (src/host-route-action-state.test.ts → same error, Tests no tests). So I proved the plugin by driving it directly with a stubbed expo/config-plugins, feeding it Expo SDK 55's real template value for MainActivity:

BEFORE configChanges = keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode
AFTER  configChanges = keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize|density
resizeableActivity   = true
NEWLY ADDED          = smallestScreenSize,density
REMOVED              = (none)

Edge cases, same harness:

idempotent      = true          # a second prebuild produces an identical string
no dup keys     = true
bare activity   = screenSize|smallestScreenSize|density|orientation|screenLayout
no empty token  = true          # empty existing configChanges does not yield a leading '|'
preserves expo  = true          # every key Expo already declared survives

Idempotency matters because expo prebuild runs repeatedly; a naive string concat would accumulate duplicates. The plugin uses a Set, so it doesn't.

Registration verified — a config plugin that isn't listed in app.json's plugins array is dead code. The diff adds "./plugins/android-split-screen-fix.js" to that array, alongside the existing android-respect-rotation-lock.js.

I did not run expo prebuild and diff the generated AndroidManifest.xml. That would be stronger, but it needs the Android SDK and network access that aren't available here. Stating that plainly rather than implying a verification I didn't perform.

Proof of no regressions

  • Additive only. The plugin unions into configChanges; the probe confirms REMOVED = (none) and that all six Expo defaults survive.
  • iOS untouched. withAndroidManifest is Android-only; no iOS code path or config is modified.
  • No app code changed. The diff is two files: a new plugin and one line in app.json. No TypeScript, no runtime behavior outside the manifest.
  • Mobile test suite: could not be executed (pre-existing expo/tsconfig.base.json resolution failure, reproduced on clean main). No test was modified or removed.

Behavior that changes for users: on Android, dragging the split-screen divider no longer recreates the activity, so in-progress UI state survives a resize. Nothing else.

Compatibility

  • Platforms: Android only. resizeableActivity has no effect on API 31+ (this app's target), so on current devices the observable change is entirely from smallestScreenSize/density. On older devices (API 24–30) the explicit resizeableActivity="true" is a harmless restatement of the default. iOS, macOS, Linux, and Windows are untouched.
  • SSH / remote: N/A — build-time Android manifest generation, no runtime, network, or host interaction.
  • Performance: No runtime cost. This changes a manifest attribute consumed at install time. If anything it reduces work, since the activity is no longer destroyed and the React tree remounted on every split-divider drag.

Screenshots

No screenshot. Split-screen behavior can only be demonstrated on a physical Samsung/Android device or emulator, which isn't available in this environment, and a mocked-up image would not evidence anything. The manifest transformation — which is the entire change — is shown as literal before/after output under Proof of fix.

Testing

  • pnpm lint — not run; this PR touches only mobile/, and the root lint suite does not cover it.
  • pnpm typecheck — not applicable; the plugin is plain CommonJS JavaScript with no TypeScript surface, and app.json is data.
  • pnpm test — cannot run. The mobile/ Vitest suite fails to start in this environment on expo/tsconfig.base.json resolution; verified pre-existing on clean main, not caused by this PR.
  • pnpm build — not run (requires the Android SDK).
  • Added or updated high-quality tests, or explained why not — I wrote a five-case Vitest spec for the plugin (default-template, preservation, resizeableActivity, idempotency, bare-activity) but did not include it, because the suite it would live in cannot execute here and I won't add a test I can't demonstrate passing. The same five cases are proven above via the standalone harness. A maintainer who can run mobile tests should land that spec; I'm happy to attach it.

AI Review Report

Reviewed with Claude Code (Opus 5). Cross-platform review confirmed: this is an Android-only, build-time manifest change with no shortcut, label, path, shell, or Electron surface, and no iOS effect. Findings:

  • Is this a no-op? Checked first, because it very nearly is. resizeableActivity defaults to true at targetSdk >= 24 and is ignored on API 31+; on Expo 55 / RN 0.83 that means the headline attribute changes nothing on any device users are likely running. Reported honestly in ## Summary rather than shipping a placebo. The configChanges half is real and is why the PR is worth landing.
  • Activity recreation — the risk I most wanted to check, and it's the one the plugin actually fixes. Making an activity resizable without covering size keys in configChanges causes destroy/recreate on every resize; the plugin adds exactly smallestScreenSize and density, the two Expo omits.
  • Plugin registration — verified present in app.json's plugins array. An unregistered plugin is silent dead code.
  • Idempotency and merge safety — Set-based union, verified to preserve all existing keys, produce no duplicates across repeated application, and handle an activity with no configChanges without emitting an empty token.
  • Attribute placement — resizeableActivity is set on <activity> via getMainActivityOrThrow, which is correct; it is valid on both <activity> and <application>, and the activity-level placement is the narrower, intended one.
  • No Samsung-specific cargo cult — the plugin does not add speculative vendor metadata (e.g. com.samsung.android.multidisplay.keep_process_alive), which I'd have flagged as unjustified.

Security Audit

  • Input handling: none. The plugin reads and writes a manifest object during prebuild.
  • Command execution: none.
  • Path handling: none — no filesystem paths are constructed or joined.
  • Auth / secrets: none touched.
  • Dependencies: none added. expo/config-plugins is already a transitive dependency used by the existing android-respect-rotation-lock.js plugin.
  • IPC: untouched.
  • Permissions/exposure: the change does not add an Android permission, exported component, or intent filter. resizeableActivity and configChanges do not widen the app's attack surface.

Notes

  • Recommend retitling to reflect what actually changes — e.g. "fix(android): stop the activity restarting when the split-screen divider is dragged". The current title credits the attribute that has no effect on the target SDK.
  • The Vitest spec described under Testing is ready to land once the mobile suite can run; it's a straight port of the harness cases shown above.
  • Untested on real Samsung One UI hardware. The manifest transformation is proven; the resulting device behavior is inferred from documented Android semantics, and a maintainer with a device should sanity-check the divider-drag case before release.

Original patch by @techinpark.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Android configuration registers a new local Expo plugin. The plugin updates the main Android activity to enable resizing and merges required configChanges values for split-screen resize events.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly matches the main change: Android split-screen/multi-window support for Samsung devices.
Description check ✅ Passed The description follows the required template and covers summary, screenshots, testing, AI review, security, and notes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 277a26a8-5907-41ab-bfc6-ce3efc0fab76

📥 Commits

Reviewing files that changed from the base of the PR and between 1c54171 and 3d5a619692980959a64dbced85ea29c655266b01.

📒 Files selected for processing (13)
  • mobile/app.json
  • mobile/plugins/android-split-screen-fix.js
  • src/cli/args.ts
  • src/cli/handlers/core.ts
  • src/cli/runtime/launch.ts
  • src/main/index.ts
  • src/main/runtime/device-registry.ts
  • src/main/runtime/runtime-rpc.ts
  • src/renderer/src/components/sidebar/PairedDevicesPanel.tsx
  • src/renderer/src/components/sidebar/index.tsx
  • src/renderer/src/web/web-pairing.ts
  • src/shared/mobile-relay-pairing-offer.ts
  • src/shared/runtime-types.ts

Comment thread mobile/app.json Resolved
Comment thread src/main/runtime/runtime-rpc.ts Resolved

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (3)
src/main/runtime/runtime-rpc.ts (3)

561-565: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename revokeMobileDevice to reflect its broadened scope.

Since this method now revokes both mobile and desktop scoped devices, consider renaming it to revokeRemoteDevice (and updating its callers) to better reflect its new behavior.


701-712: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify relay revocation logic for desktop pairing.

Since desktop pairing explicitly rejects relays, the connectionMode argument no longer influences relay behavior. The switchingPendingToLocal check, copied from the mobile logic, can be safely removed. Any hypothetically stranded relay bindings on a desktop pending device (e.g., from older, unreleased buggy builds) can simply be revoked when a rotation is requested.

♻️ Proposed refactor
-    const switchingPendingToLocal =
-      args.connectionMode === 'local-only' && pending?.relayBinding !== undefined
-    if (args.rotate || switchingPendingToLocal) {
-      if (pending?.relayBinding) {
-        this.queueRelayDeviceRevoke(pending.relayBinding)
-      }
+    if (args.rotate && pending?.relayBinding) {
+      this.queueRelayDeviceRevoke(pending.relayBinding)
     }
     const direct = this.createPairingOffer({
       ...args,
-      rotate: args.rotate || switchingPendingToLocal,
+      rotate: args.rotate,
       scope: 'desktop'
     })

1115-1126: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename MOBILE_RPC_METHOD_ALLOWLIST to reflect its broadened scope.

Now that this allowlist gates both mobile and desktop scopes (and the error message correctly refers to "remote clients" on line 1121), consider renaming the constant (defined on line 164) to REMOTE_RPC_METHOD_ALLOWLIST for clarity.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f02457ee-5f9c-4f4a-8fa4-96c0f4779d01

📥 Commits

Reviewing files that changed from the base of the PR and between 3d5a619692980959a64dbced85ea29c655266b01 and 6d37a024d3b6a00aa019ebfbae59030fb8a63622.

📒 Files selected for processing (3)
  • mobile/app.json
  • src/main/runtime/runtime-rpc.ts
  • src/renderer/src/components/sidebar/PairedDevicesPanel.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/sidebar/PairedDevicesPanel.tsx

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for the PR. @Jinwoo-H will review it soon

Samsung OneUI requires explicit android:resizeableActivity=true in the
main activity manifest to render correctly in split-screen and pop-up
window modes. Without it the app letterboxes instead of filling the split.

Changes:
- Introduce android-split-screen-fix.js config plugin to inject
  resizeableActivity and screenSize|smallestScreenSize|density|orientation
  |screenLayout into the activity's configChanges so resizing does not
  trigger an activity restart.
- Register the plugin in app.json; keep resizeableActivity out of app.json
  directly because Expo's schema does not expose that field.

Fixes: Samsung Android split-screen 'does not fill the screen' issue
@techinpark
techinpark force-pushed the fix/android-split-screen-samsung branch from 6d37a02 to 29afdcf Compare July 18, 2026 02:04
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:35
@nwparker

Copy link
Copy Markdown
Contributor

Maintainer review. I dug into this against the real Expo SDK 55 prebuild pipeline, and unfortunately this change is very close to a no-op on the manifest Orca actually ships — for reasons that aren't obvious from reading the diff. Details below so the analysis is reproducible.

1. The configChanges half is already in Expo's template

The PR description says:

android:configChanges did not include screenSize / smallestScreenSize, so dragging the split divider triggered an activity restart

That premise doesn't hold. Expo's bare template — which is what expo prebuild generates from, and which the release workflow (.github/workflows/mobile-android-release.yml) runs — already ships:

<activity android:name=".MainActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize" ...>

screenSize, smallestScreenSize, orientation and screenLayout are all already there. Of the five keys the plugin adds, four are already present. The only net-new key is density.

I verified this by running the plugin in this PR, unmodified, through the real @expo/[email protected] mod pipeline, against the real mobile/app.json (with the sibling android-respect-rotation-lock.js plugin also applied, to match production ordering):

--- generated <activity> WITHOUT this PR (current main) ---
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="fullUser">

--- generated <activity> WITH this PR ---
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize|density" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:resizeableActivity="true" android:screenOrientation="fullUser">

  configChanges ADDED  : [ 'density' ]
  configChanges REMOVED: []

So the entire real-world delta of this PR is: +android:resizeableActivity="true" and +density.

2. resizeableActivity="true" is the default, and is ignored on our target

Per the <application> manifest docs:

For apps targeting API level 24 or higher, the default is "true".

Orca mobile is on Expo SDK 55, which defaults minSdkVersion 24 / targetSdkVersion 35, and nothing in mobile/app.json, expo-build-properties, or the release workflow overrides it. Since we target ≥ 24, resizeableActivity was already true implicitly — writing it explicitly changes nothing.

It gets more emphatic above API 31, which every device that can run split-screen on a modern build will be:

If your app targets API level 31 or higher... Large screens (sw >= 600dp): all apps support multi-window mode.

And on API 36:

To improve the layout of apps on form factors with smallest width >= 600dp, the system ignores this attribute for apps that target Android 16 (API level 36).

So on the phone-sized Samsung devices in the bug report the attribute was already defaulting to true, and on tablet/DeX-sized surfaces the system disregards it entirely. There is no configuration in which setting it to its own default value makes split-screen start working.

3. This means the reported bug has a different root cause

I want to be clear that I am not disputing the bug — letterboxing in Samsung split-screen is a real, frequently-reported class of problem. What I'm saying is that this patch can't be what fixes it, so landing it would close the issue without resolving it.

The likelier culprit, which is actually Orca-specific and worth investigating, is mobile/plugins/android-respect-rotation-lock.js. It pins android:screenOrientation="fullUser" on the main activity. Android's multi-window docs note:

In multi-window mode, Android might disable or ignore features that don't apply to an activity that is sharing the device screen... The system ignores changes to the android:screenOrientation attribute.

"Ignores" is the documented AOSP behavior; Samsung One UI is well known for diverging here and applying compat/letterboxing when an activity carries a fixed-orientation request. That's a concrete, testable hypothesis and it points at code we own. A fixed-orientation activity is also exactly the input that triggers Android's compatibility-mode letterboxing — which matches the "centered with black margins" symptom far better than a missing default-valued attribute does.

4. The one real change carries a small unverified risk

Adding density to configChanges isn't inert: it stops the activity being recreated when display density changes (display-size/font-scale settings, or moving to an external display — i.e. Samsung DeX). That's usually desirable, but it means density-derived values are no longer refreshed by a recreate. MobileBrowserPane.tsx:357 memoizes on [browserViewMode, layout] while reading PixelRatio.get():

const streamRequest = useMemo(
  () => buildMobileBrowserScreencastRequest(layout, PixelRatio.get(), browserViewMode),
  [browserViewMode, layout]
)

PixelRatio.get() is not in the dep array, so post-change a density shift that doesn't also change layout could leave a stale pixel ratio in the screencast request. I have not reproduced this on hardware — flagging it as residual risk, not a confirmed defect. It's a real behavior change though, and it's the only behavior change here.

Recommendation

I'm recommending we not merge this as-is: the configChanges additions are already covered by Expo's template, resizeableActivity="true" restates a default that's ignored on our target SDK, and the only net change (density) is unrelated to split-screen sizing and carries a small stale-density risk. Merging it would add a config plugin that must be maintained forever while leaving the actual bug in place.

@techinpark — thank you for this, and please don't read the above as dismissing the report. The investigation was sound and the symptom you documented is real; the resizeableActivity advice is genuinely the top search result for this problem, it's just stale guidance from the API 24-era that Android has since defaulted and then overridden. If you're able to test on your Samsung device, the highest-value experiment would be removing android:screenOrientation="fullUser" from android-respect-rotation-lock.js in a local build and checking whether split-screen then fills the pane correctly. If it does, that's the real fix and it's a change we'd very much want — it would also tell us we need to reconcile rotation-lock behavior with multi-window, which is a genuinely interesting problem.

Reproduction notes for whoever picks this up: the manifests above were generated with @expo/[email protected] and [email protected] (matching mobile/package.json), applying both repo plugins to mobile/app.json via compileModsAsync. No Android SDK or device required.

@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
@nwparker

Copy link
Copy Markdown
Contributor

I’m working through the mobile bug shortlist, including this Android split-screen lifecycle fix. I’ll review and credit the original patch, reproduce the activity restart, and validate a focused fix on an Android emulator with before/after evidence.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @techinpark for the original multi-window patch. I reviewed it and checked the native Android behavior before adapting it.

I could not reproduce ordinary split-divider resizing restarting Orca in the tested current configuration. Expo 55.0.31's actual template and a clean Android prebuild at dda855e837d0e86c6f0694ae52ce4ccefcf76d62 already declare:

android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize"

I then installed the official v0.0.58 APK (versionCode 22; SHA-256 98a91cc9bc02031e12c1daf7f752c2a32ec85ba6d41c2de32847b1ab1712940e) on a headless Android 15 / API 35 Pixel Tablet emulator, 2560×1600 at 320 dpi. Its packaged manifest agrees (configChanges=0xfb0); its Expo version, app config, and Android plugins match the source checked above.

With Settings beside Orca, I opened “Paste pairing code,” typed resize-check-9190, and dragged the real divider from half width to one-third, back to half, then to two-thirds. The drawer and text survived all three drags. Native activity dumps confirmed the changing bounds and constant 320 dpi. The event buffer contained zero MainActivity create/destroy/relaunch events during those drags.

Two sizes from the unmodified app:

One-third width, drawer and typed text preserved

Two-thirds width, drawer and typed text preserved

As a separate control, adb shell wm density 360 did produce wm_relaunch_resume_activity, wm_on_destroy_called, and wm_on_create_called, and cleared the drawer. That confirms the lifecycle check detects recreation. It establishes a distinct display-density trigger; ordinary divider dragging did not change density in this test.

ELI5: the current app already keeps its place when the divider moves. Changing Android's display scale is a different operation and can still reset the open drawer.

I'm recording the ordinary split-resize report as not reproduced in this environment, with no replacement split-screen PR. This does not establish Samsung One UI behavior; that needs Samsung-specific reproduction evidence. The remaining density change should be evaluated under its precise trigger rather than presented as a proven fix for divider dragging.

@Nelef

Nelef commented Oct 30, 2026

Copy link
Copy Markdown

@nwparker following up on your request for Samsung-specific evidence: #36305 has logs and videos from a Galaxy Z Fold7 (One UI 9.0, Android 17).

  • Entering and leaving split screen changes the window density (360 → 321 dpi), and that is what recreates MainActivity (changed={…, CONFIG_DENSITY}). Divider drags don't, matching your Pixel Tablet result.
  • Adding only density stops the restart but leaves React Native's display metrics at the old density: the split pane is drawn too small and button labels clip.
  • fix(mobile): render correctly in Android multi-window density mismatch #20853's Android plugin adds density and re-seeds DisplayMetricsHolder from the window; on the same device it fixed both.

So density alone shouldn't land on its own; #20853's approach covers the One UI case.

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for this! Split screen is now fixed in #36977, which adds density to configChanges and re-seeds React Native's display metrics from the activity.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants