ionic-team / ionic-team/capacitor

[Bug]: Crash on Chromebooks running Android 11 in WebViewFeature.isFeatureSupported(WEB_MESSAGE_LISTENER)

Open
#7,853 6 comments 0 reactions 0 assignees View on GitHub
triage
Dominant language
TypeScript
Stars
16.7k
Forks
1.3k
Avg merge
3d 15h
Merged PRs (30d)
10

Description

### Capacitor Version

$ npx cap doctor
[warn] The bundledWebRuntime configuration option has been deprecated. Can be safely deleted.
💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: unknown
@capacitor/core: unknown
@capacitor/android: unknown
@capacitor/ios: unknown

Installed Dependencies:

@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/android: 6.1.1
@capacitor/ios: 6.1.1

[success] iOS looking great! 👌
[success] Android looking great! 👌

### Other API Details

```Shell
$ npm --version
10.9.2
$ node --version
v23.5.0
```

### Platforms Affected

- [ ] iOS
- [x] Android
- [ ] Web

### Current Behavior

I have the following crash:
```
Fatal Exception: java.lang.RuntimeException: Unknown feature WEB_MESSAGE_LISTENER
at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:628)
at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:597)
at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:591)
at com.getcapacitor.MessageHandler.(MessageHandler.java:26)
at com.getcapacitor.Bridge.(Bridge.java:220)
at com.getcapacitor.Bridge$Builder.create(Bridge.java:1560)
at com.getcapacitor.BridgeFragment.load(BridgeFragment.java:86)
```

when running on Chromebooks with Android 11. Specifically:
- 96% - Google Cros:
- 83% -AMD Stoney Ridge Chromebook
- 9% - Intel Jasper Lake Chromebook
- 4% - Intel Gemini Lake Chromebook
- 4% - Hewlett-Packard
- 4% - 1650

### Expected Behavior

Capacitor should not crash when a

### Project Reproduction

I can't reproduce this because I don't have a Chromebook running Android 11

### Additional Information

This code still exists in [7.0.1's `MessageHandler.java`](https://github.com/ionic-team/capacitor/blob/7.0.1/android/capacitor/src/main/java/com/getcapacitor/MessageHandler.java#L26), so I suspect this is still a `7.0.1` bug.

I suggest the following:
```
boolean isWebMessageListenerSupported = false;
try {
isWebMessageListenerSupported = WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)
} catch (Throwable ignored) {
// Some WebView installs throw exceptions when we inquire about features it doesn't know about
// Example: RuntimeException - Unknown feature WEB_MESSAGE_LISTENER
}
if (isWebMessageListenerSupported && !bridge.getConfig().isUsingLegacyBridge()) {
...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.