[TIMOB-16082] Android: WebView.evalJS always returns null on Android 4.2.2 device
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-08-18T15:51:21.000+0000 |
Affected Version/s | Release 3.2.0 |
Fix Version/s | Release 6.2.0 |
Components | Android |
Labels | Android, WebView, evalJs, exalture, kitkat |
Reporter | SHOCKOE TEAM |
Assignee | Joshua Quick |
Created | 2013-12-17T22:24:01.000+0000 |
Updated | 2017-08-18T15:51:21.000+0000 |
Description
WebView.evalJS appears to always return null on devices running Android Kit-Kat, regardless of the provided script.
Example app:
var win = Titanium.UI.createWindow({
title:'EvalJS kit-kat test',
backgroundColor:'#fff'
});
var webView = Ti.UI.createWebView({
url : 'http://www.google.com'
});
webView.addEventListener('load', function(evt){
//Expected behavior is for an alert saying 'google' to be shown
//On Android Kit-Kat, an empty alert is shown instead.
alert(evt.source.evalJS('document.title'));
});
win.add(webView);
win.open();
Reproduces on 3.1.3.GA and 3.2.0.v20131210191510
I have not been able to reproduce this problem on Nexus 7 phone running Android 4.4 with 3.1.3 SDK. I am wondering if you encounter this issue only on Android 4.4 device or can you reproduce this issue on other devices as well? Can you reproduce this issue on the simulator too? I would appreciate if you can also try an alternate website in the above example.
same here, evalJS always return null for 3.2 SDK, Android 4.0
Moving this ticket to engineering as I can reproduce it on Samsung Galaxy Nexus (4.2.2) device.
Hi All--Since this was reproduced on 4.2.2, should we rewrite the ticket to not be KitKat specific?
Same issue on Galaxy Nexus running 4.3. Build with Ti SDK 3.2.0.GA
Reproduced on Samsung Galaxy S4 running 4.3 and Nexus 4 running 4.4 with Ti SDK 3.1.2.GA
I think the problem originates in this: http://developer.android.com/guide/webapps/migrating.html ??Android 4.4 (API level 19) introduces a new version of WebView that is based on Chromium. This change upgrades WebView performance and standards support for HTML5, CSS3, and JavaScript to match the latest web browsers. Any apps using WebView will inherit these upgrades when running on Android 4.4 and higher.??
Same problem with Nexus 5 (Android 4.4.4, SDK 3.3.0). Any workaround?
I no longer have this when I just do:
Just found the code again which handles this: [ti.ui.widget.webview.TiWebViewBinding.java](https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewBinding.java) Line 147: getJsValue
confirmed return is needed on Android (tested on Nexus 5, Android 5.0.1) but cause return null on iOS wtf
Any updates on this ticket?
Could not reproduce. Tried with 4.2.X-4.4.X, 6 and 7.X emulators. Alert dialogue returned expected non-null values.
Since this issue is not reproducible I'm going to close this as invalid.