Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1890] Local HTML / JS working on IOS not Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-10-22T17:48:31.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labels3.1.2GA, 3.1.3, Android, IOS
ReporterJohn Schimanski
AssigneeMotiur Rahman
Created2013-09-30T14:23:03.000+0000
Updated2016-03-08T07:40:48.000+0000

Description

This code var barcode =Ti.UI.createWebView({ top:"30%", left:"33%", height:"25%", width:"37%", url: "/local/jscode39.html" }) barcode.addEventListener('beforeload', function(e) { barcode.evalJS("var sku='"+barcodesku+"';"); }); Presents the barcode in IOS just like it should but just produces a blank white slate on Android 4.0. In the console it produces the following warnings and errors [WARN][webview ( 1051)] java.lang.Throwable: Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads. [WARN][webview ( 1051)] at android.webkit.WebView.checkThread(WebView.java:9355) [WARN][webview ( 1051)] at android.webkit.WebView.getSettings(WebView.java:4053) [WARN][webview ( 1051)] at android.webkit.ZoomManager.getReadingLevelScale(ZoomManager.java:317) [WARN][webview ( 1051)] at android.webkit.WebView.getReadingLevelScale(WebView.java:2448) [WARN][webview ( 1051)] at android.webkit.WebViewCore.setupViewport(WebViewCore.java:2487) [WARN][webview ( 1051)] at android.webkit.WebViewCore.didFirstLayout(WebViewCore.java:2258) [WARN][webview ( 1051)] at android.webkit.WebViewCore.nativeUpdateFrameCache(Native Method) [WARN][webview ( 1051)] at android.webkit.WebViewCore.access$4900(WebViewCore.java:55) [WARN][webview ( 1051)] at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1458) [WARN][webview ( 1051)] at android.os.Handler.dispatchMessage(Handler.java:99) [WARN][webview ( 1051)] at android.os.Looper.loop(Looper.java:137) [WARN][webview ( 1051)] at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:722) [WARN][webview ( 1051)] at java.lang.Thread.run(Thread.java:856) Then I run it again and get thisDEBUG][Module ( 702)] Loading module: alloy/controllers/ticketview -> Resources/alloy/controllers/ticketview.js [DEBUG][TiAssetHelper( 702)] Fetching "alloy/controllers/ticketview.js" with Fastdev... [DEBUG][TiFastDev( 702)] (KrollRuntimeThread) [1572,7939] sent tokens successfully [DEBUG][TiFastDev( 702)] (KrollRuntimeThread) [6,7945] sent tokens successfully [DEBUG][dalvikvm( 702)] GC_CONCURRENT freed 385K, 4% free 12813K/13319K, paused 4ms+7ms [DEBUG][dalvikvm( 77)] GREF has increased to 401 [WARN][webcore ( 702)] java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up. [WARN][webcore ( 702)] at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1671) [WARN][webcore ( 702)] at android.webkit.WebViewCore$EventHub.access$7800(WebViewCore.java:920) [WARN][webcore ( 702)] at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1783) [WARN][webcore ( 702)] at android.webkit.WebView.sendOurVisibleRect(WebView.java:2858) [WARN][webcore ( 702)] at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:586) [WARN][webcore ( 702)] at android.webkit.ZoomManager.access$1700(ZoomManager.java:49) [WARN][webcore ( 702)] at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:977) [WARN][webcore ( 702)] at android.os.Handler.handleCallback(Handler.java:605) [WARN][webcore ( 702)] at android.os.Handler.dispatchMessage(Handler.java:92) [WARN][webcore ( 702)] at android.os.Looper.loop(Looper.java:137) [WARN][webcore ( 702)] at android.app.ActivityThread.main(ActivityThread.java:4340) [WARN][webcore ( 702)] at java.lang.reflect.Method.invokeNative(Native Method) [WARN][webcore ( 702)] at java.lang.reflect.Method.invoke(Method.java:511) [WARN][webcore ( 702)] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) [WARN][webcore ( 702)] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) [WARN][webcore ( 702)] at dalvik.system.NativeStart.main(Native Method) [INFO][TiAPI ( 702)] sku = 223456789 [WARN][webview ( 702)] java.lang.Throwable: Warning: A WebView method was called on thread 'WebViewCoreThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads. [WARN][webview ( 702)] at android.webkit.WebView.checkThread(WebView.java:9355) [WARN][webview ( 702)] at android.webkit.WebView.getSettings(WebView.java:4053) [WARN][webview ( 702)] at android.webkit.ZoomManager.getReadingLevelScale(ZoomManager.java:317) [WARN][webview ( 702)] at android.webkit.WebView.getReadingLevelScale(WebView.java:2448) [WARN][webview ( 702)] at android.webkit.WebViewCore.setupViewport(WebViewCore.java:2487) [WARN][webview ( 702)] at android.webkit.WebViewCore.didFirstLayout(WebViewCore.java:2258) [WARN][webview ( 702)] at android.webkit.WebViewCore.nativeUpdateFrameCache(Native Method) [WARN][webview ( 702)] at android.webkit.WebViewCore.access$4900(WebViewCore.java:55) [WARN][webview ( 702)] at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1458) [WARN][webview ( 702)] at android.os.Handler.dispatchMessage(Handler.java:99) [WARN][webview ( 702)] at android.os.Looper.loop(Looper.java:137) [WARN][webview ( 702)] at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:722) [WARN][webview ( 702)] at java.lang.Thread.run(Thread.java:856) [INFO][TiWebChromeClient.console( 702)] (main) [2532,10477] Uncaught SyntaxError: Unexpected token var (1:file:///android_asset/Resources/local/jscode39.html) [WARN][TiWebViewBinding( 702)] (KrollRuntimeThread) [2293,12770] Timeout waiting to evaluate JS [INFO][WindowManager( 77)] createSurface Window{41603098 Panel:com.cstg.ticket1/com.cstg.ticket1.Ticket1aActivity paused=false}: DRAW NOW PENDING [DEBUG][dalvikvm( 702)] GC_CONCURRENT freed 394K, 4% free 13294K/13831K, paused 4ms+10ms I can see the SKU variable has something in it (through TI.API.info commands and in the console) but apparently its not getting to the JS file in the local directory. The file structure is APP Resources local then the HTML / JS and the gif images to load the barcode white and black bars on IOS it works like a champ (both in the simulator and a device) but not android either in the emulator or on a device Thanks John

Comments

  1. Motiur Rahman 2013-10-07

    Hi John Schimanski, Could you share your js or HTML file so that i can reproduce this issue. I have tested html file titanium 3.1.3 android 4.0 but it works. Thanks
  2. John Schimanski 2013-10-07

    Motiur, Do you want me to upload the files ? I am new to the JIRA system so I am not sure how you wish me to share the files. please let me know. john
  3. John Schimanski 2013-10-07

    here is the JS code from titanium var barcodesku = "1234567890"; var barcode =Ti.UI.createWebView({ top:"30%", left:"33%", height:"25%", width:"100%", backgroundColor: "red", url: "/local/jscode39.html" }) barcode.addEventListener('beforeload', function(e) { barcode.evalJS("var sku='"+barcodesku+"';"); }); $.index.add(barcode); $.index.open(); here is the file that it is calling from the url line. named jscode39.html and this is the actual JS file that the html file calls . it is names code39.jslocal // JavaScript BarCode39 v. 1.0 (c) Lutz Tautenhahn, 2005 // The author grants you a non-exclusive, royalty free, license to use, // modify and redistribute this software. // This software is provided "as is", without a warranty of any kind. Chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"; Codes=new Array( "111221211","211211112","112211112","212211111","111221112","211221111","112221111","111211212", "211211211","112211211","211112112","112112112","212112111","111122112","211122111","112122111", "111112212","211112211","112112211","111122211","211111122","112111122","212111121","111121122", "211121121","112121121","111111222","211111221","112111221","111121221","221111112","122111112", "222111111","121121112","221121111","122121111","121111212","221111211","122111211","121121211", "121212111","121211121","121112121","111212121"); BarPic=new Array(2); BarPic[0]=new Image(); BarPic[0].src="b.gif" BarPic[1]=new Image(); BarPic[1].src="w.gif" function Code39(theX, theY, theBarHeight, theFontHeight, theBarCodeText, theBarCodeSize) { var pp="", ff, ss=1; if (theBarCodeSize) ss=parseInt(theBarCodeSize); if (isNaN(ss)) ss=1; if (ss<1) ss=1; if ((theX!="")&&(theY!="")) pp="position:absolute;left:"+theX+";top:"+theY+";"; if ((theFontHeight>4)&&(theBarHeight>=2*theFontHeight)) { ff="style='font-size:"+theFontHeight+"px;font-family:Verdana;'"; document.write("
    "); document.write(""); for (i=0; i"+CodePics(theBarCodeText.charAt(i),theBarHeight-theFontHeight-1, ss)+""); document.write(""); document.write(""); for (i=0; i"+theBarCodeText.charAt(i)+""); document.write("
    "+CodePics("*",theBarHeight, ss)+""+CodePics("*",theBarHeight, ss)+"
    "); } else { document.write("
    "); document.write(""); for (i=0; i"+CodePics(theBarCodeText.charAt(i),theBarHeight, ss)+""); document.write("
    "+CodePics("*",theBarHeight, ss)+""+CodePics("*",theBarHeight, ss)+"
    "); } } function CodePics(theChar, theHeight, theSize) { var ss="", cc="9", ii=Chars.indexOf(theChar); if (ii>=0) cc=Codes[ii]; for (ii=0; ii"; ss+=""; return(ss); } it has two GIF files that it calls for the black and white bars on the screen. When I run it in IOS it runs just fine and I can see the barcode. When I run it on Android 4.0.2 i get the webview core error messages and all I see i the background color (red). I got the barcode images from http://barcode-coder.com/en/barcode-jquery-plugin-201.html any idea what i am doing wrong? John
  4. Mauro Parra-Miranda 2013-10-22

    Hello, can you please check this? http://stackoverflow.com/questions/8413912/in-appcelerator-titanium-mobile-when-using-local-html-in-a-webview-how-do-i-lo the Web prefix is not the same in iOS and Android, that's the reason it fails in android and work in iOS. Best, Mauro

JSON Source