[TIMOB-17613] Unable to execute javascript code using evalJS on Android with SDK 3.3.0.GA
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-09-15T17:37:10.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.4.0 |
Components | Android |
Labels | 3.3.0, Android, Titanium, evalJS, module_android, qe-testadded |
Reporter | Ivo |
Assignee | Hieu Pham |
Created | 2014-09-03T15:57:15.000+0000 |
Updated | 2014-11-20T15:50:52.000+0000 |
Description
Attachments
File | Date | Size |
---|---|---|
Screen Shot 2014-09-03 at 5.08.00 PM.png | 2014-09-03T15:57:16.000+0000 | 236063 |
We have this issue in our enterprise app, relying on evaluating js functions embedded in remote html pages rendered in a WebView. We use this as kind of event mechanism, for the app to take control on certain user actions done on the remote web site. I have tested Ivo's sample on a real device, Samsung Galaxy Note 10.1. Works on SDK 3.2.3, does not work on SDK 3.3.0! This is a blocking issue for us, cannot upgrade the SDK. Please fix in the next SDK. Thanks
From TIMOB-15896, is it possible for you to try adding the annotation and see if that fixes the issue for you? It would require you to build a custom SDK, but it would help speed up resolution.
After doing some investigation on the changes done on this file https://github.com/appcelerator/titanium_mobile/blob/3_3_X/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewBinding.java#L153 We believe that we have located the problem, which according us is not related to missing annotation in the code (note that annotation is already present, and according to the Android documentation this has effect only on API >= 17). Instead, we think that the problem is introduced by newly added code, which does some pattern matching before evaluating the Javascript expression. The conslusion was made by comparing the same file from 3.2.X and 3.3.X (copy the contents of both files in some diff tool). After reverting this code, and building the Titanium SDK from scratch, it seems that the issue is resolved. However, we believe that this code was put there for some reason, thus removing it is not the best idea. We would be very gratefull if you fix the problem with the pattern/matcher and provide the fix in the next SDK release.
Thank you! That's very helpful.
The original test case (from TIMOB-10837):
Seems we need to add a few more cases to make sure we evaluate them correctly. I'm assuming we can simplify the example above. Is it just because it's a self-invoking function?
Marking as for 3.4.0 unless we come up with a suitable workaround.
master PR: https://github.com/appcelerator/titanium_mobile/pull/6026 3.4.X PR: https://github.com/appcelerator/titanium_mobile/pull/6027
Verified the fix. After running the code in the description we now get :
which is expected behaviour & shows the execution of javascript code using evalJS. Closing. Environment: Appc Studio : 3.4.0.201409112242 Ti SDK : 3.4.0.v20140912084114 Mac OSX : 10.9.4 Alloy : 1.5.0-rc CLI - 3.4.0-rc2 Code Processor: 1.1.1 Genymotion Emulator - android 4.1.1
This happens again on 3.4.1GA on Lollipop. On Android 4.4.2 it's all fine.
Please ignore my previous comment. It was premature.