Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15896] WebView's evalJS method times out on Android API >= 17

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionDuplicate
Resolution Date2014-09-07T22:06:30.000+0000
Affected Version/sRelease 3.2.0
Fix Version/sRelease 3.4.0
ComponentsAndroid
Labelsandroid, defect, evaljs, javascript, webview
ReporterNuno Sousa
AssigneeIngo Muschenetz
Created2013-11-27T15:09:20.000+0000
Updated2017-03-22T23:10:10.000+0000

Description

Since API 17, any WebView that intends to expose a Javascript object must decorate methods with the @JavascriptInterface annotation, as described [here](http://developer.android.com/guide/webapps/webview.html). The [TiReturn class](https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewBinding.java#L174) does not use this annotation which is why I believe that any evalJS call simply returns null and outputs: bq. W/TiWebViewBinding( 3268): (KrollRuntimeThread) Timeout waiting to evaluate JS

Comments

  1. Mostafizur Rahman 2013-12-04

    Tested this issue with code below and reproduced the error.

    Testing Environment:

    OS: MAC OS X 10.8.5 Ti SDK: 3.1.3 GA ,3.2.0.x Ti CLI: 3.3.0 Android Device 4.2.2 Android SDK 4.4

    Test Code

       Titanium.UI.setBackgroundColor('#000');
       
       var win1 = Titanium.UI.createWindow({
       	title : 'Tab 1',
       	backgroundColor : '#fff',
       	navBarHidden : true
       });
       
       var webview = Titanium.UI.createWebView({
       	url : 'pass.html'
       });
       win1.add(webview);
       
       var str = "Hello world!";
       webview.evalJS("var message='" + str + "';");
       
       win1.open();
       
       
    pass.html
       
       <!DOCTYPE html>
       <html lang="en">
       	<head>
       		<meta charset="utf-8">
       
       	</head>
       
       	<body>
       		<script type="text/javascript">
       			alert(message);
       		</script>
       
       	</body>
       </html>
       

    Logs

       
       ERROR][WindowManager(  386)] Starting window AppWindowToken{b3129128 token=Token{b2fd9658 ActivityRecord{b2fa2a88 u0 com.mrtechnologybd.smartmeter/.QnaActivity t2}}} timed out
       [WARN][V8Object( 1508)] Runtime disposed, cannot set property 'userAgent'
       [INFO][dalvikvm-heap( 1508)] Grow heap (frag case) to 4.767MB for 1536016-byte allocation
       [ERROR][NetdConnector(  386)] NDC Command {65 bandwidth gettetherstats} took too long (761ms)
       [WARN][WebViewProxy( 1508)] (KrollRuntimeThread) [6235,6235] WebView not available, returning null for evalJS result.
       [WARN][linker  ( 1508)] libtiverify.so has text relocations. This is wasting memory and is a security risk. Please fix.
       [INFO][TiRootActivity( 1508)] (main) [0,0] checkpoint, on root activity resume. activity = com.mrtechnologybd.smartmeter.QnaActivity@b2e02388
       [INFO][ActivityManager(  386)] START u0 {cmp=com.mrtechnologybd.smartmeter/org.appcelerator.titanium.TiActivity (has extras)} from pid 1508
       [INFO][Choreographer( 1508)] Skipped 43 frames!  The application may be doing too much work on its main thread.
       [WARN][ActivityManager(  386)] Activity pause timeout for ActivityRecord{b2fa2a88 u0 com.mrtechnologybd.smartmeter/.QnaActivity t2}
       [INFO][Choreographer( 1508)] Skipped 144 frames!  The application may be doing too much work on its main thread.
       [INFO][LatinIME]LogUtils(  543): Dictionary info: dictionary = UserHistoryDictionary.en_US.dic ; version = ? ; date = 1386135904
       [INFO][chromium( 1508)] [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
       [INFO][BrowserProcessMain( 1508)] Initializing chromium process, renderers=0
       [INFO][PerformBackupTask(  386)] Initializing (wiping) backup state and transport storage
       [WARN][chromium( 1508)] [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
       [ERROR][chromium( 1508)] [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
       [ERROR][chromium( 1508)] [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
       [ERROR][chromium( 1508)] [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
       [ERROR][chromium( 1508)] [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
       [ERROR][chromium( 1508)] [ERROR:gpu_info_collector.cc(86)] gfx::GLSurface::InitializeOneOff() failed
       [INFO][Choreographer(  386)] Skipped 30 frames!  The application may be doing too much work on its main thread.
       [ERROR][PerformBackupTask(  386)] Error invoking for backup on @pm@
       [INFO][PerformBackupTask(  386)] Backup pass finished.
       [ERROR][PerformBackupTask(  386)] Duplicate finish
       
    Thanks
  2. Gertjan Smits 2014-07-18

    Is this still on the radar? The issue still exists in SDK 3.3.0.GA.
  3. Shuo Liang 2014-07-31

  4. Ingo Muschenetz 2014-09-04

    Has anyone tried adding the appropriate annotation to the class noted to see if that resolves the issue for them?
  5. Ingo Muschenetz 2014-09-07

    Resolving as duplicate of linked issue.
  6. Lee Morris 2017-03-22

    Closing ticket as duplicate as the relevant ticket is linked above.

JSON Source