Skip to content

fix(mobile): prevent black flashes during Android text selection - #36892

Closed
gentslava wants to merge 1 commit into
stablyai:mainfrom
gentslava:fix/android-selection-surface
Closed

gentslava wants to merge 1 commit into
stablyai:mainfrom
gentslava:fix/android-selection-surface

Conversation

@gentslava

@gentslava gentslava commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Adjusting Android's text-selection handles can flash the chat background black and make the conversation unreadable. Keep the WebView on a dedicated GPU texture while text is selected, then release it when selection ends.

What Changed

  • Use an Android WebView subclass that acquires a hardware layer for the native selection action mode and restores the previous layer when creation is refused or the action mode ends.
  • Forward the original menu callbacks and Callback2 content rectangle so selection actions and toolbar positioning continue to work.

Why

The affected phone reproduces this in a full-window WebView during magnifier dragging. Native background color, an opaque HTML background, and a composited page root all still fail. A dedicated hardware layer prevents the flash. Limiting it to selection avoids keeping an extra full-window GPU texture during ordinary chat use.

Linked Issue

Fixes #36553

Visual Proof

Affected Nothing A065, Android 16, WebView 158.0.8127.2. These are English-only captures from an isolated full-window reproduction using production RN Web styles and the production chat scroller. The after capture runs the exact new Java class; private conversations are excluded.

Before: default WebView layer After: hardware layer during selection
Black transcript while dragging the selection handle Readable transcript while dragging the same selection handle

Testing

  • Manually reproduced the reported defect in installed Orca Mobile 0.0.61 on the affected physical phone using normal long-press and handle-drag input.
  • Same-phone full-window A/B: default WebView failed 4/4 drags; the scoped layer passed 12 light-mode drags, including deselect/reselect, and 4 dark-mode drags.
  • Observed the native layer transition 0 -> 2 -> 0 after selection starts and is dismissed, including dark mode.
  • Compiled the exact new class against Android API 36, converted it with D8, packaged it into the isolated diagnostic APK, and executed it on the phone.
  • Reporter confirmed in the actual Orca Mobile app on the affected phone that flickering disappeared after updating the Android APK (2026-11-01).
  • git diff --check.
  • Automated tests added/updated, or explained why not: the failure requires Android's actual window compositor and magnifier. The device A/B above is the rendering regression evidence; a JVM test or desktop selection test would not exercise that surface path.

The complete Expo Android release APK builds successfully with this patch. Its checksum and APK signature were verified. Application-level acceptance is now reporter-confirmed on the affected phone (2026-11-01): updating the desktop alone did not remove the flicker; it disappeared only after installing the updated Android APK. This is the reporter's result in Orca Mobile, distinct from the instrumented A/B in the isolated diagnostic app above. The native WebView change is delivered by the APK, so a desktop/page-bundle update alone cannot install this fix. Broad repository checks are left to CI.

Handset revalidation after the page-only fix — 2026-11-03

Retested the actual paired Orca Mobile application on the affected Nothing A065 (Android 16, Adreno 730, WebView 158.0.8127.2), with both opaque-scroller changes from #36905 present. The served transcript/tab-strip files match the merged PR and current main byte for byte; the official 0.0.61 native WebView source also matches current main.

  • Official Orca Mobile 0.0.61 without this native patch: 2/2 native selection-handle drags still blacken the transcript and tab strip while the magnifier is visible.
  • Restored 0.0.61 APK containing this patch, with the same page and paragraph: 0/2 drags blacken the background.

Both variants used normal UI input, were recorded, and were checked by installed APK digest. No DOM selection was injected and no application data was reset. This is evidence for the relevant selection paths, rather than every unrelated change in a clean full-main build. Raw recordings remain local because they contain a private conversation. This native fix is therefore still needed on the affected handset alongside #36905.

AI Disclosure

Implemented and investigated with OpenAI Codex. Device results above were verified through native Android UI input.

Review

Android-only native implementation; desktop platforms and iOS have no source changes. Local/remote hosts, mixed host versions, supported agents/integrations, and folder/git workspaces use the same existing bridge contract. GPU rendering stays enabled; the additional texture is scoped to selection. Menu actions/content rectangles are delegated, and the existing WebView isolation settings remain in their existing factory.

Agent skill upstream boundary

  • Not applicable; no skill-installer source or assets are included.

Author

GitHub: @gentslava. X/Twitter: N/A.

Checklist

  • This PR is small and focused.
  • User-facing behavior, mechanism, alternatives and device evidence are described.
  • Before/after screenshots attached.
  • Self-reviewed for security, compatibility, UI behavior and performance.
  • Full repository checks and full Expo APK validation complete.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: daaedf8e-ba88-434d-9128-1a6f96acb717
Commits

Reviewing files that changed from the base of the PR and between fbb3381 and 66e2bbf.

Files selected for processing: 2
  • mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellSelectionView.java
  • mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellView.kt

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

Walkthrough

The Android mobile web shell now creates a MobileWebShellSelectionView. The subclass wraps text-selection action-mode callbacks, enables hardware rendering while selections are active, and restores the original layer type when the last selection ends.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 66e2b

No concrete merge-blocking risk was identified in the reviewed Android selection-rendering changes.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preventing black flashes during Android text selection.
Linked Issues check Passed The change satisfies the coding requirements in [#36553]. MobileWebShellView.kt now creates MobileWebShellSelectionView. The subclass switches to LAYER_TYPE_HARDWARE when selection action mode c…
Out of Scope Changes check Passed The whole-PR change is limited to the Android WebView subclass and the existing WebView factory. The layer handling, callback forwarding, and factory substitution directly support [#36553]. No unrelat…
Description check Passed The pull request description is complete and follows the required structure. It explains the user impact, implementation, rationale, linked issue, visual proof, testing evidence, AI disclosure, compat…
Full details: Linked Issues check

Explanation

The change satisfies the coding requirements in [#36553]. MobileWebShellView.kt now creates MobileWebShellSelectionView. The subclass switches to LAYER_TYPE_HARDWARE when selection action mode creation succeeds and restores the previous layer when creation is refused or the mode is destroyed. It forwards menu callbacks and Callback2.onGetContentRect, which preserves selection behavior and toolbar positioning. The reported device validation covers the affected Android environment. No linked issue requires an automated test for this compositor-specific defect.

Full details: Out of Scope Changes check

Explanation

The whole-PR change is limited to the Android WebView subclass and the existing WebView factory. The layer handling, callback forwarding, and factory substitution directly support [#36553]. No unrelated platform, bridge, workspace, or product behavior changes are present in the reviewed diff.

Full details: Description check

Explanation

The pull request description is complete and follows the required structure. It explains the user impact, implementation, rationale, linked issue, visual proof, testing evidence, AI disclosure, compatibility considerations, and checklist status. The final checklist leaves broad repository checks unchecked, but it clearly states that CI will cover them and provides substantial Android validation.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks @gentslava for tracking this down and testing on the handset. We landed #36905, which paints the transcript and tab strip scrollers opaque, so I'm closing this one.

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.

Android chat flashes black while dragging selection or cursor handles in light mode

2 participants