apache / apache/cordova-plugin-inappbrowser

Android: executeScript failing for large return values (length greater than 10240)

Open
#303 7 comments 0 reactions 0 assignees View on GitHub
bug platform: android support
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

Since Android updated to webview v 69.0.3497.91, any script that runs that returns content longer than 10240 bytes fails as the message gets truncated

Bug appears here: https://github.com/apache/cordova-plugin-inappbrowser/blob/master/src/android/InAppChromeClient.java#L114

`JSONException` occurs as message is invalid JSON (truncated string)

Bug has been lodged with Chrome but they won't fix it:

https://bugs.chromium.org/p/chromium/issues/detail?id=884100

In the bug they report:

```
I don't think you should rely on prompt() as a means of passing data from JS to Java. There are other APIs that are properly suited to this task.
```

I am about to try a few ideas either `addJavascriptInterface` or `evaluateJavascipt` instead of `prompt` but would be open to suggestions of other interfaces

Note: This works OK if chrome is uninstalled and the default Android WebView is used

Contributor guide

Open the contributing guide

Research direction

Start at src/android/InAppChromeClient.java around line 114 and reproduce executeScript with a return value longer than 10240 bytes on Android WebView 69. Compare the reported prompt-based message path with the addJavascriptInterface and evaluateJavascript alternatives mentioned in the issue. Done means large return values arrive without truncation and no JSONException occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.