[TIMOB-1635] Android: Errors with "logging and Unicode" test cases
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:56:43.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.6.0 M04 |
Components | Android |
Labels | android, defect, release-1.6.0 |
Reporter | Thomas Huelbert |
Assignee | Don Thorp |
Created | 2011-04-15T02:57:54.000+0000 |
Updated | 2011-04-17T01:56:43.000+0000 |
Description
1.BaseUI>Views>WebViews>Loggin and unicode
2.check console output
results:
E/Web Console( 627): Uncaught TypeError: Cannot read property 'API'
of undefined at
file:///android_asset/Resources/examples/webview_logging.html:5
D/TiAPI ( 627): (kroll$31) [102,344500] webview loaded:
file:///android_asset/Resources/examples/webview_logging.html
Thomas, just curious, was the failcase from a device or the emulator? I'm getting weird mixed behavior. (You can assign to me after answering)
Sorry for the omitted info Bill - this was device only (worked on the simulator when I tested it) - nexus one running 2.2
Ok, cool, I have the exact same behavior pattern. Fails on my HTC Desire using 2.2, works in an emulator (I tried it with a 2.1 emulator but will also try 2.2).
So this has been broken (on devices -- at least 2.2) basically forever. I tried even for Titanium 1.3:
That
D/webkit-timers(19880)
line is interesting. It does not occur in the emulator!Still researching...
Here is the core Android code for
WebView.addJavascriptInterface()
, which we use to putTiAPI
andTiApp
in the javascript scope:Messages in
mWebViewCore
are handled on a separate thread. Maybe the loading of a page in the webview is actually fast enough to occur before our objects are added to the javascript scope.In my tests on an HTC Desire running Android 2.2, this page loaded in a WebView and required the
setTimeout
to run once (with just 100 milliseconds) beforeTi.API
was available:(from [12d7bf6a90db72fa0aebe538c95128c8a0cdc625]) Inject our Ti JS and JSON near beginning of local (and ONLY local) html file contents or html set directly via the html property. [#2153 state:fixed-in-qa][#2514 state:fixed-in-qa][#1635 state:fixed-in-qa][#1036 state:fixed-in-qa] https://github.com/appcelerator/titanium_mobile/commit/12d7bf6a90db72fa0aebe538c95128c8a0cdc625"> https://github.com/appcelerator/titanium_mobile/commit/12d7bf6a90db...
This works great on 2.2 devices, but on 1.6 the test fails with:
I/ActivityManager( 76): Starting activity: Intent { cmp=com.appcelerator.pushtest/org.appcelerator.titanium.TiActivity (has extras) }
I/ActivityManager( 76): Displayed activity com.appcelerator.pushtest/org.appcelerator.titanium.TiActivity: 175 ms (total 175 ms)
I/global ( 641): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
D/WebCore ( 641): Console: ReferenceError: Can't find variable: Ti line: 5 source: file:///android_asset/Resources/examples/webview_logging.html
Maybe a fact of life on 1.6? back to Bill.
(from [3452f061796695f0ad14d49fe3b22689f2e27dce]) [#1635 state:fixed-in-qa] Android webkit MimeTypeMap does not have a mime type for file extension html until Android version 2.2. So we need to add it to our own mime type map in order for html files to be recognized as text/html and therefore get our javascript code injected. https://github.com/appcelerator/titanium_mobile/commit/3452f061796695f0ad14d49fe3b22689f2e27dce"> https://github.com/appcelerator/titanium_mobile/commit/3452f0617966...
[INFO] Titanium SDK version: 1.6.0 (01/10/11 08:25 3452f06) G1 (1.6) and the 1.6 emulator.
seems like the problem persists with the latest nightly build [INFO] Titanium SDK version: 1.6.0 (01/22/11 23:17 9177466...)
the Titanium variable is just not available to the android simulator even after a wait of 60 seconds (tested using Bill Dawson's method above) making the API completely unavailable for use on remote web pages. The page was generated with PHP but the output is equal to what Bill Dawson provided.