[TIMOB-27189] Webview:Onlink property is not working properly
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Done |
Resolution Date | 2019-08-21T03:57:29.000+0000 |
Affected Version/s | Release 8.0.2 |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Rakhi Mitro |
Assignee | Unknown |
Created | 2019-06-27T08:50:17.000+0000 |
Updated | 2019-08-21T19:17:20.000+0000 |
Description
The customer is facing this issue on using *onlink* property of webview. On SDK 8.0.2.GA when webview is created though xml file using onlink property of webview, it provides run time error(android) and the app is crashing on iOS device.
*Note:*
The customer noticed that *onlink* is working properly only if the webview is created inside the controller. We also tested this. On iOS,it worked properly but on android,it provides run time error.
*Test Steps:*
1. Open Studio
2. Copy the sample code and paste via studio
3. Run on android and ios both. The app is crashing on iOS. On android, we got run time error in console.
*Test code:*
*index.js*
var handleBeforeLoadListener = function(evt) {
console.log(JSON.stringify(evt));
};
$.webComponent.url = 'webpage.html';
$.index.open();
index.xml
<Alloy>
<Window class="container">
<WebView id="webComponent" onlink="handleBeforeLoadListener" />
</Window>
</Alloy>
*Test Output:*
*iOS Crashlog:*
[ERROR] : The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] : Reason:
[ERROR] : -[__NSCFString executeWithArguments:]: unrecognized selector sent to instance 0x2810962e0
[ERROR] : Stack trace:
[ERROR] : 0 CoreFoundation 0x000000023a1c0530 <redacted> + 252
[ERROR] : 1 libobjc.A.dylib 0x000000023939b9f8 objc_exception_throw + 56
[ERROR] : 2 CoreFoundation 0x000000023a0dd278 <redacted> + 0
[ERROR] : 3 CoreFoundation 0x000000023a1c5d60 <redacted> + 1408
[ERROR] : 4 CoreFoundation 0x000000023a1c79fc _CF_forwarding_prep_0 + 92
[ERROR] : 5 Onlink 0x000000010458455c Onlink + 263516
[ERROR] : 6 WebKit 0x00000002497b3440 <redacted> + 584
[ERROR] : 7 WebKit 0x0000000249819fd4 <redacted> + 2544
[ERROR] : 8 WebKit 0x000000024981957c <redacted> + 376
[ERROR] : 9 WebKit 0x00000002498193cc <redacted> + 108
[ERROR] : 10 WebKit 0x0000000249a19c08 <redacted> + 108
[ERROR] : 11 WebKit 0x0000000249a146e0 <redacted> + 100
[ERROR] : 12 WebKit 0x000000024967deb0 <redacted> + 120
[ERROR] : 13 WebKit 0x000000024983b320 <redacted> + 32
[ERROR] : 14 WebKit 0x000000024966ea20 <redacted> + 148
[ERROR] : 15 WebKit 0x0000000249671510 <redacted> + 712
[ERROR] : 16 JavaScriptCore 0x00000002412d3aa0 <redacted> + 276
[ERROR] : 17 JavaScriptCore 0x00000002412d3d60 <redacted> + 36
[ERROR] : 18 CoreFoundation 0x000000023a1522bc <redacted> + 24
[ERROR] : 19 CoreFoundation 0x000000023a15223c <redacted> + 88
[ERROR] : 20 CoreFoundation 0x000000023a151b24 <redacted> + 176
[ERROR] : 21 CoreFoundation 0x000000023a14ca60 <redacted> + 1004
[ERROR] : 22 CoreFoundation 0x000000023a14c354 CFRunLoopRunSpecific + 436
[ERROR] : 23 GraphicsServices 0x000000023c34c79c GSEventRunModal + 104
[ERROR] : 24 UIKitCore 0x00000002665b8b68 UIApplicationMain + 212
[ERROR] : 25 Onlink 0x000000010454b624 Onlink + 30244
[ERROR] : 26 libdyld.dylib 0x0000000239c128e0 <redacted> + 4
*Android:*
ERROR] : TiAssetHelper: Error while opening asset "Resources/alloy/controllers/webpage.html":
[ERROR] : TiAssetHelper: java.io.FileNotFoundException: Resources/alloy/controllers/webpage.html
[ERROR] : TiAssetHelper: at android.content.res.AssetManager.openAsset(Native Method)
[ERROR] : TiAssetHelper: at android.content.res.AssetManager.open(AssetManager.java:690)
[ERROR] : TiAssetHelper: at android.content.res.AssetManager.open(AssetManager.java:664)
[ERROR] : TiAssetHelper: at org.appcelerator.kroll.util.KrollAssetHelper.openAsset(KrollAssetHelper.java:135)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.io.TiResourceFile.getInputStream(TiResourceFile.java:72)
[ERROR] : TiAssetHelper: at ti.modules.titanium.ui.widget.webview.TiUIWebView.setUrl(TiUIWebView.java:612)
[ERROR] : TiAssetHelper: at ti.modules.titanium.ui.widget.webview.TiUIWebView.processProperties(TiUIWebView.java:462)
[ERROR] : TiAssetHelper: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1296)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:506)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:462)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:513)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:462)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:602)
[ERROR] : TiAssetHelper: at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:305)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:57)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:578)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:726)
[ERROR] : TiAssetHelper: at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
[ERROR] : TiAssetHelper: at android.app.Activity.performCreate(Activity.java:7372)
[ERROR] : TiAssetHelper: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.-wrap12(Unknown Source:0)
[ERROR] : TiAssetHelper: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
[ERROR] : TiAssetHelper: at android.os.Handler.dispatchMessage(Handler.java:108)
[ERROR] : TiAssetHelper: at android.os.Looper.loop(Looper.java:166)
[ERROR] : TiAssetHelper: at android.app.ActivityThread.main(ActivityThread.java:7425)
[ERROR] : TiAssetHelper: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiAssetHelper: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
[ERROR] : TiAssetHelper: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
[ERROR] : TiExceptionHandler: (main) [11,502] null
[ERROR] : TiExceptionHandler:
[ERROR] : TiExceptionHandler: java.io.Reader.<init>(Reader.java:78)
[ERROR] : TiExceptionHandler: java.io.InputStreamReader.<init>(InputStreamReader.java:97)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.widget.webview.TiUIWebView.setUrl(TiUIWebView.java:613)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.widget.webview.TiUIWebView.processProperties(TiUIWebView.java:462)
[ERROR] : TiExceptionHandler: org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1296)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:506)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:462)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:513)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:462)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:602)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:305)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:57)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:578)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:726)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
[ERROR] : TiExceptionHandler: android.app.Activity.performCreate(Activity.java:7372)
[ERROR] : TiExceptionHandler: android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.-wrap12(Unknown Source:0)
[ERROR] : TiExceptionHandler: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
[ERROR] : TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:108)
[ERROR] : TiExceptionHandler: android.os.Looper.loop(Looper.java:166)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:7425)
[ERROR] : TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiExceptionHandler: com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
[ERROR] : TiExceptionHandler: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
[ERROR] : TiExceptionHandler: (main) [1,503] null
[ERROR] : TiExceptionHandler:
[ERROR] : TiExceptionHandler: java.io.Reader.<init>(Reader.java:78)
[ERROR] : TiExceptionHandler: java.io.InputStreamReader.<init>(InputStreamReader.java:97)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.widget.webview.TiUIWebView.setUrl(TiUIWebView.java:613)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.widget.webview.TiUIWebView.processProperties(TiUIWebView.java:462)
[ERROR] : TiExceptionHandler: org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1296)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:506)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:462)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:513)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:462)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:602)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:305)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:57)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:578)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:726)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
[ERROR] : TiExceptionHandler: android.app.Activity.performCreate(Activity.java:7372)
[ERROR] : TiExceptionHandler: android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.-wrap12(Unknown Source:0)
[ERROR] : TiExceptionHandler: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
[ERROR] : TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:108)
[ERROR] : TiExceptionHandler: android.os.Looper.loop(Looper.java:166)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:7425)
[ERROR] : TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiExceptionHandler: com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
[ERROR] : TiExceptionHandler: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Attachments
File | Date | Size |
---|---|---|
Onlink.zip | 2019-07-11T15:29:38.000+0000 | 8704762 |
Hello [~gmathews], [~jquick], Can you please look into this issue. We are able to reproduce the issue. Thanks.
[~sdarda], regarding the Android issue, it has nothing to do with "onlink". The "FileNotFoundException" is telling you exactly what's wrong. It's failing to find the HTML file. The issue is the WebView was given a "relative path" to the HTML file. The relative path handling between Android and iOS are different. On Android, file paths are relative to the JavaScript file (or XML file in Alloy) that invoked it. On iOS, file paths are relative to the app's "Resources" directory. The best solution is to give it an "absolute path" to the HTML file. So, the solution is to change this...
...to the below...
Using an absolute path as shown above will work on both Android and iOS.
Hello [~jquick], The issue in the iOS is still there after making the above change. App still crashes in open
Can you please try the attached project. Using the absolute path the error in endroid is solved. The iOS crash is still occuring with the 8.0.2.GA SDK. Thanks.
This seems to be a limitation in Alloy. You can't assign functions directly to properties like it is required for
onlink
. *EDIT:* The workaround i provided before did not work. [~jquick] is currently trying out another solution.The following will work on both Android and iOS. You should set the onlink callback to empty string in the XML file and then set the onlink property directly in your JavaScript. Also, don't forget the leading slash for the HTML file to reference it by absolute path since relative path handling is different between Android and iOS. index.xml
index.js
[~sdarda], Jan has deleted his code from his comment in favor of mine. My change will work. Try it out.
Hello [~jquick], your code worked. I have deleted my other reply. Can you confirm what was wrong on the previous code and also in the customer code? If this is a limitation in Alloy as Jan said, any plan on fixing this in the future or maybe document the way of handling onlink in iOS? Thanks for the guide.
Hello [~jquick], Thank you for the information. Also, thanks for creating the other ticket. I already provided your solution to the customer. Customer will be happy to see the improvement ticket. I will update the customer on that. Do you think we keep this ticket open? or we can close it? Thanks for your support.