Skip to content

Conversation

@jayohms
Copy link
Contributor

@jayohms jayohms commented Jun 18, 2025

This makes it possible to detect out-of-the-box when the system WebView component is outdated on a device. This can happen (to developers) when using an older Android Emulator without Play Services or (to users) when Google Chrome or Android System WebView automatic app updates have been disabled in the Play Store.

Rails 8 requires Chrome 120+ for its default configuration:

allow_browser versions: :modern

Rails returns an HTTP 406 when an unsupported Chromium WebView version tries to access the server. To make this easier to identify, the following improvements have been added:

Log warning

A new debug log will be present when using a WebView version older than WebViewInfo.REQUIRED_WEBVIEW_VERSION, which is currently set to 120. Example log warning:

D WebView info ...................... [session: navigation, package: com.google.android.webview, type: Android System WebView, version: 112]
W WebView outdated .................. [The Chromium WebView installed on the device is outdated. Minimum version 120 is required for modern browsers in Rails 8. If you're using an emulator, ensure it has Play Services enabled and install the latest WebView version from the Play Store: market://details?id=com.google.android.webview]

Error screen with description

The default error view included in the framework now includes the specific VisitError description. For an HTTP 406, this will read:

Error loading page
Not Accessible

Outdated WebView alert dialog

Developers can now use the new WebViewVersionCompatibility class to display an alert dialog in their app if the WebView version is outdated. Call it like:

WebViewVersionCompatibility.displayUpdateDialogIfOutdated(
    activity = this,
    requiredVersion = WebViewInfo.REQUIRED_WEBVIEW_VERSION // or whatever version you require
)

This dialog looks like the following screenshot and allows a user to update the WebView component through the Play Store:
Screenshot_20250618-171617

@jayohms jayohms requested a review from joemasilotti June 18, 2025 21:24
@jayohms jayohms merged commit 29abe8b into main Jun 19, 2025
1 check passed
@jayohms jayohms deleted the outdated-webview-warning branch June 19, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants