From c4e4428af7d399a23e2e916943b7a2cb7dcf7560 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:32:37 +0000 Subject: [PATCH] fix(mobile): say which WebView to install when Android's is too old to open a workspace (#40907) * fix(mobile): tell Android users which WebView to update when it is too old The page shell needs androidx's DOCUMENT_START_SCRIPT:1, which stable WebView only reports from Chromium 101; the comments claimed 83/88. Name the required WebView and the one installed, and how to switch it. * fix(mobile): read the WebView provider through the shell module index Tests stub the module index; a direct file import loaded expo-modules-core unstubbed. --- .../MobileWebShellBridge.kt | 2 +- .../MobileWebShellDocument.kt | 2 +- .../MobileWebShellNetworkApiBlocker.kt | 2 +- .../OrcaMobileWebShellModule.kt | 13 ++++++++ .../orca-mobile-web-shell/src/index.ts | 19 +++++++++++- mobile/src/i18n/locales/en.json | 2 ++ .../src/mobile-web-shell/ShellStateScreen.tsx | 30 +++++++++++++++++-- 7 files changed, 64 insertions(+), 6 deletions(-) diff --git a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellBridge.kt b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellBridge.kt index 045cce54908..99f8bfc2713 100644 --- a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellBridge.kt +++ b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellBridge.kt @@ -38,7 +38,7 @@ internal enum class MobileWebShellBridgeInstall { /** The prop is false, so nothing is registered and Phase B behaviour is byte-identical. */ SKIP, INSTALL, - /** The WebView provider is older than `WEB_MESSAGE_LISTENER` (Chromium 88). Terminal. */ + /** The WebView provider is older than `WEB_MESSAGE_LISTENER` (Chromium 83). Terminal. */ UNAVAILABLE } diff --git a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellDocument.kt b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellDocument.kt index af1aff6a343..0d8f77c5fc5 100644 --- a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellDocument.kt +++ b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellDocument.kt @@ -201,7 +201,7 @@ internal class MobileWebShellDocument(private val context: Context) { view.destroy() } - // Keep explicit settings for the Chromium 83 floor, even where newer WebViews ignore deprecated options. + // Keep explicit settings even where newer WebViews ignore deprecated options; the floor is Chromium 101. // B4 requires device proofs: no network, persistent state, file/content access, cleartext or navigation escape. @Suppress("DEPRECATION") private fun createWebView(): WebView { diff --git a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellNetworkApiBlocker.kt b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellNetworkApiBlocker.kt index 4c0397fdd0a..0b94103df6e 100644 --- a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellNetworkApiBlocker.kt +++ b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellNetworkApiBlocker.kt @@ -17,7 +17,7 @@ internal val MOBILE_WEB_SHELL_NETWORK_API_BLOCKER = """ })(); """.trimIndent() -/** Query document-start-script capability (Chromium 83 floor), not version strings. */ +/** Query capability, not version strings; stable WebView has it from Chromium 101. */ internal fun installMobileWebShellNetworkApiBlocker( webView: WebView, allowedOrigin: String diff --git a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/OrcaMobileWebShellModule.kt b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/OrcaMobileWebShellModule.kt index abba9fd7675..e08436bd126 100644 --- a/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/OrcaMobileWebShellModule.kt +++ b/mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/OrcaMobileWebShellModule.kt @@ -8,6 +8,8 @@ import android.content.res.Configuration import android.net.Uri import android.os.Handler import android.os.Looper +import androidx.webkit.WebViewCompat +import androidx.webkit.WebViewFeature import expo.modules.kotlin.exception.CodedException import expo.modules.kotlin.exception.Exceptions import expo.modules.kotlin.functions.Queues @@ -68,6 +70,17 @@ class OrcaMobileWebShellModule : Module() { Uri.fromFile(directory).toString() } + // Lets isolation-unavailable name the WebView to update. + Function("currentWebViewProvider") { + val context = appContext.reactContext ?: return@Function null + val info = WebViewCompat.getCurrentWebViewPackage(context) ?: return@Function null + val version = info.versionName ?: return@Function null + val name = info.applicationInfo?.loadLabel(context.packageManager)?.toString() ?: info.packageName + val hasShellFeatures = WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT) && + WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER) + mapOf("name" to name, "version" to version, "hasShellFeatures" to hasShellFeatures) + } + AsyncFunction("prepareSpareDocument") { directory: String, sessionId: String -> val activity = appContext.currentActivity ?: return@AsyncFunction false MobileWebShellSparePool.prepare(activity, directory, sessionId) diff --git a/mobile/modules/orca-mobile-web-shell/src/index.ts b/mobile/modules/orca-mobile-web-shell/src/index.ts index 97979cd7019..4e072e2efb2 100644 --- a/mobile/modules/orca-mobile-web-shell/src/index.ts +++ b/mobile/modules/orca-mobile-web-shell/src/index.ts @@ -18,7 +18,7 @@ export type OrcaMobileWebShellViewProps = ViewProps & { generationDirectory: string /** `[A-Za-z0-9_-]{1,128}`. Scopes the private origin, so every mount must mint a fresh one. */ sessionId: string - // Bridge is off by default with nothing registered. Opt-in on Android below WEB_MESSAGE_LISTENER/Chromium 88 fails isolation-unavailable instead of loading unfenced. + // Bridge is off by default with nothing registered. Opt-in on Android below WEB_MESSAGE_LISTENER/Chromium 83 fails isolation-unavailable instead of loading unfenced. bridgeEnabled?: boolean onLoadState?: (event: NativeSyntheticEvent) => void // Raw JSON from window.orcaBridge; native silently rejects other origins/frames/WebViews and envelopes above 640 KiB (MobileWebShellBridge.maxMessageByteCount). @@ -82,6 +82,23 @@ export function warmUpWebShell(): void { } } +export type WebViewProvider = { name: string; version: string; hasShellFeatures: boolean } + +// Android only: the WebView provider and whether it has the shell's fences. Null when unknown. +export function currentWebViewProvider(): WebViewProvider | null { + if (Platform.OS !== 'android') { + return null + } + const shell = requireOptionalNativeModule<{ + currentWebViewProvider?: () => WebViewProvider | null + }>('OrcaMobileWebShell') + try { + return shell?.currentWebViewProvider?.() ?? null + } catch { + return null + } +} + export { MOBILE_WEB_SHELL_FAILURE_REASONS, parseMobileWebShellLoadState, diff --git a/mobile/src/i18n/locales/en.json b/mobile/src/i18n/locales/en.json index f14faed6778..cac5f2aa90f 100644 --- a/mobile/src/i18n/locales/en.json +++ b/mobile/src/i18n/locales/en.json @@ -820,6 +820,8 @@ "webShell": { "shellStateScreen": { "isolationUnavailable": "This device's WebView is too old to open the workspace safely.", + "isolationUnavailableAndroid": "Orca needs Android System WebView or Chrome 101 or newer. Update it from the Play Store, or pick a newer one in Developer options > WebView implementation.", + "webViewInUse": "This device has {{name}} {{version}}.", "downloadFailed": "The latest app could not be downloaded from this host.", "hostProfileUnreadable": "Could not read this host on your device. Try again.", "statusUnreadable": "Could not read this host's status. Go back and reopen it.", diff --git a/mobile/src/mobile-web-shell/ShellStateScreen.tsx b/mobile/src/mobile-web-shell/ShellStateScreen.tsx index d22e7e2c055..bc9d7ccaa91 100644 --- a/mobile/src/mobile-web-shell/ShellStateScreen.tsx +++ b/mobile/src/mobile-web-shell/ShellStateScreen.tsx @@ -1,5 +1,6 @@ import type { ReactNode } from 'react' -import { Pressable, Text, View } from 'react-native' +import { Platform, Pressable, Text, View } from 'react-native' +import { currentWebViewProvider } from '../../modules/orca-mobile-web-shell/src' import { ProtocolBlockScreen } from '../components/ProtocolBlockScreen' import { colors, radii, spacing, typography } from '../theme/mobile-theme' import { themedStyleSheet } from '../theme/themed-styles' @@ -65,11 +66,30 @@ function Failed({ useMobileColorScheme() // Retry cannot change a settled isolation gate or give an unsupported WebView the missing fence. const retryable = state.reason !== 'isolation-unavailable' && state.reason !== 'status-unreadable' + const provider = state.reason === 'isolation-unavailable' ? currentWebViewProvider() : null + // Unknown provider (older binary): a missing feature is still the likely cause. + const webViewTooOld = + Platform.OS === 'android' && + state.reason === 'isolation-unavailable' && + provider?.hasShellFeatures !== true return ( - {failureMessage(state.reason, t)} + {webViewTooOld + ? t( + 'webShell.shellStateScreen.isolationUnavailableAndroid', + 'Orca needs Android System WebView or Chrome 101 or newer. Update it from the Play Store, or pick a newer one in Developer options > WebView implementation.' + ) + : failureMessage(state.reason, t)} + {webViewTooOld && provider ? ( + + {t('webShell.shellStateScreen.webViewInUse', 'This device has {{name}} {{version}}.', { + name: provider.name, + version: provider.version + })} + + ) : null} {retryable ? ( [styles.retryButton, pressed && styles.pressed]} @@ -160,6 +180,12 @@ const styles = themedStyleSheet(() => ({ textAlign: 'center', marginBottom: spacing.lg }, + failedDetail: { + fontSize: typography.metaSize, + color: colors.textSecondary, + textAlign: 'center', + marginBottom: spacing.lg + }, retryButton: { backgroundColor: colors.bgRaised, paddingVertical: spacing.sm + 2,