[TIMOB-25387] Android Ti.App.addEventListener not working when there is an iframe in local html file
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 6.2.2 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Anthony Chung |
Assignee | Unknown |
Created | 2017-10-04T05:54:50.000+0000 |
Updated | 2018-02-28T19:55:28.000+0000 |
Description
Test case provided here...
Environment, android, Ti. 6.1.1.GA plus.
[https://github.com/anthonychung/jira-appcelerator-tests/tree/issues/test-android-iframe-fireevent]
Android Ti.addEventListener not working when there is an iframe in local html file
<script>
Ti.App.addEventListener("app:fromTitanium", function(e) {
alert(e.message);
});
</script>
This will work when local html has no iframe.
When there is an iframe in android local html content,
Ti.addEventListener no longer works.
This issue appears to be related to Android webview overwrites the jscontext for the parent, with the child's jscontext. Whereas, on ios, it preserves the parent jscontext. And since the Ti.App.addEventListener is a part of the parent's context (I assume it is injected with __ti_injection into the parent and not the child). Then ios handles the support for this correctly. But Android is wiping out the parent web application. This is a critical issue for our application, because the American DOD ADL SCORM standard requires that the parent iframe expose apis for the child eLearning SCORM packages to talk to. Other frameworks seem to have faced this problem. https://stackoverflow.com/questions/9050949/webview-on-android-ics-iframe-problems-with-android-assets/10210172#10210172 Part of it is android webview, but another is that it affects the function of the Ti.App.addEventListeners. [~hknoechel] Have appc clients come across this issue before and is there are workaround? I will follow up also follow up with your official chat/support channel. Any advice related to this issue would be appreciated.
Hello! I tested the issue and reproduce it with the following environment Ti SDK: 6.2.2.GA, 6.1.2.GA Android Emulator: 7,6 Android Device: v4.4.2 Steps To Reproduce 1. Run the following code 2. Click the button "From Titanium", (event is not firing, this is the issue) 3. If you remove the iframe from the html code then it works again.
Thanks
Hi, is there any news on this issue? I have been running extra tests. In Android, the load event fires twice. This could be causing issues for the ti_injection. When I set up listeners on the child. Then it works. But I need the listeners on the parent. Android has a different event called onPageStarted that is fired when an iframe page is loaded, this can help distinguish from the double load event. If the ti_injection code needs to be adapted, the injection needs to happen on the parent and not the child load event. Checking the local html code for the presence of 'iframe' on android can help to avoid doing the injection on the second load event and if something needs to be performed when everything is loaded then we can look for onPageStared on Android. https://developer.android.com/reference/android/webkit/WebViewClient.html#onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap)
[~hknoechel] any chance of getting your perspective on this issue?