String message of onJsPrompt parameter are only showed 1024byte of it.
Reported by
boeun3...@gmail.com,
Sep 14
|
||
Issue descriptionTHIS TEMPLATE IS FOR FILING BUGS ON THE ANDROID SYSTEM WEBVIEW. GENERAL WEB BUGS SHOULD BE FILED USING A DIFFERENT TEMPLATE! Device name: BrailleSensePolaris (Hims.Inc) Android version: Android 5.1 WebView version (from system settings -> Apps -> Android System WebView): 69.0.3497.91 Application: WebBrowser(I had developed it) Application version: URLs (if applicable): http://www.himsintl.co.kr Steps to reproduce: (1) Start web browser.(Above url is default url of it) Expected result: Show above site. Without any access error. Actual result: There is access error when I start web browser. FYI, From yesterday, the day you have upgrade webview version to 69.0.3497.91 some access error happened. I tried to find what the problem is. So, I found that. The reason is related to onJsPrompt method of WebChromeClient. The message which is one of the parameters onJsPrompt is not fully sended. The message has cut into 1024 byte string event thought the actual size of it is 10kbytes. I have coded like as follows. //At JavaScript. function han_prompt(message) { prompt(message); // This message length is 10kbyte. } //At Java @Override public boolean onJsPrompt(WebView view, final String url, String message, String defaultValue, JsPromptResult result) { JSONObject msgObject = new JSONObject(message); //Json exception occured because the message is cut into 1024bytes. String str = msgObject.getString(...); } ** I want to know the the reason why you guys restrict string message which is a parameter of onJsPrompt method length to 1024bytes.
,
Sep 14
I'm sorry. It's not 1024bytes. It's 10240bytes.
,
Sep 14
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. For your reference, the change was made here: https://chromium-review.googlesource.com/c/chromium/src/+/1112471
,
Sep 24
,
Sep 25
Issue 888775 has been merged into this issue.
,
Sep 25
> There are other APIs that are properly suited to this task. I assume you're referring to @JavascriptInterface methods. If that's the case, can it be guaranteed that we won't have size limitations on parameters passed to these methods in the future? (And is there in fact a size limit on them currently?) > // 10k ought to be enough for anyone. I see what you did there!
,
Sep 25
Ideally you should use the postMessage APIs, but addJavascriptInterface has a lower minsdk. You can also use the androix.webkit support library to expand the coverage of postMessage. I'm not aware of any restrictions regarding the size of messages passed via these APIs, modulo IPC size limits.
,
Sep 25
@JavascriptInterface methods and postMessage are the actual mechanisms for communicating data between your web code and native code; the limits there are determined just by the IPC implementation as Toby mentions. The onJs* callbacks are intended solely to implement standard web browser style dialog boxes to communicate with the *user*, not for internal communication with your program, and they're subject to change as browsers' handling of these functions change (most browsers are treating these as legacy functions and restricting their usage).
,
Dec 2
The issue here is that it will subtly break old phonegap/cordova apps (or newer apps that use an older version of phonegap/cordova). The breakage could be subtle and cause lost of data, eg cropping files when writing more than 10240 bytes From what I can tell, this affects anyone using cordova/phonegap in their app, older than 4.0.0 |
||
►
Sign in to add a comment |
||
Comment 1 Deleted