{ "id": "169955", "key": "TIMOB-25387", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2017-10-04T05:54:50.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "19542", "description": "", "name": "Release 6.2.2", "archived": false, "released": true, "releaseDate": "2017-09-19" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T19:55:28.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Test case provided here...\r\nEnvironment, android, Ti. 6.1.1.GA plus.\r\n\r\n[https://github.com/anthonychung/jira-appcelerator-tests/tree/issues/test-android-iframe-fireevent]\r\n\r\n# Android Ti.addEventListener not working when there is an iframe in local html file\r\n\r\n\r\n{code:javascript}\r\n\r\n{code}\r\n\r\nThis will work when local html has no iframe.\r\nWhen there is an iframe in android local html content, \r\nTi.addEventListener no longer works.\r\n\r\n# On iOS This works fine.\r\nBut on Android, having an iframe disables the functionality of the inline javascript Ti.App.addEventListener\r\n\r\n# To test\r\n- run the app in Android, then click \"Test without iframe\" button, which will load index-noiframe.html with the eventListener, click \"Fire Event\" and the event will successfully alert.\r\n- close window, then click \"Test with iframe\" button, which will load index-noiframe.html with the eventListener, click \"Fire Event\" and the event will not work.", "attachment": [], "flagged": false, "summary": "Android Ti.App.addEventListener not working when there is an iframe in local html file", "creator": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "subtasks": [], "reporter": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "environment": "Android", "comment": { "comments": [ { "id": "428779", "author": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "body": "This issue appears to be related to Android webview overwrites the jscontext for the parent, with the child's jscontext.\r\nWhereas, on ios, it preserves the parent jscontext.\r\n\r\nAnd 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.\r\n\r\nThis 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.\r\n\r\nOther frameworks seem to have faced this problem.\r\nhttps://stackoverflow.com/questions/9050949/webview-on-android-ics-iframe-problems-with-android-assets/10210172#10210172\r\n\r\nPart of it is android webview, but another is that it affects the function of the Ti.App.addEventListeners.\r\n\r\n[~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.\r\n\r\nAny advice related to this issue would be appreciated.", "updateAuthor": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "created": "2017-10-06T08:47:37.000+0000", "updated": "2017-10-06T08:47:37.000+0000" }, { "id": "429059", "author": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello!\r\n\r\nI tested the issue and reproduce it with the following environment\r\n\r\nTi SDK: 6.2.2.GA, 6.1.2.GA\r\nAndroid Emulator: 7,6\r\nAndroid Device: v4.4.2\r\n\r\nSteps To Reproduce\r\n1. Run the following code\r\n2. Click the button \"From Titanium\", \r\n(event is not firing, this is the issue)\r\n3. If you remove the iframe from the html code then it works again.\r\n\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow();\r\n\tvar webview = Ti.UI.createWebView({\r\n\t\turl : '/index-withiframe.html'\r\n\t});\r\n\tvar button = Ti.UI.createButton({\r\n\t\ttitle : 'fromTitanium',\r\n\t\theight : '50dp',\r\n\t\twidth : '130dp'\r\n\t});\r\n\tbutton.addEventListener('click', function(e) {\r\n\t\tTi.App.fireEvent('app:fromTitanium', {\r\n\t\t\tmessage : 'event fired from Titanium, handled in WebView'\r\n\t\t});\r\n\t});\r\n\tTi.App.addEventListener('app:fromWebView', function(e) {\r\n\t\talert(e.message);\r\n\t});\r\n\r\n\twin.add(webview);\r\n\twin.add(button);\r\n\twin.open();\r\n\r\n{code}\r\n\r\n{code:title=index-withiframe.html}\r\n\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\r\n\t \r\n\t\r\n\t\r\n\r\n{code}\r\n{code:title=blank.html}\r\n\r\n\t\r\n\t\t\r\n\t\r\n\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nThanks\r\n", "updateAuthor": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2017-10-13T09:33:03.000+0000", "updated": "2017-10-14T02:04:39.000+0000" }, { "id": "429164", "author": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "body": "Hi, is there any news on this issue?\r\n\r\nI have been running extra tests.\r\nIn Android, the load event fires twice. This could be causing issues for the ti_injection.\r\nWhen I set up listeners on the child. Then it works. But I need the listeners on the parent.\r\n\r\nAndroid 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. \r\n\r\nChecking 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.\r\n\r\nhttps://developer.android.com/reference/android/webkit/WebViewClient.html#onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap)\r\n\r\n", "updateAuthor": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "created": "2017-10-17T04:37:24.000+0000", "updated": "2017-10-17T04:37:24.000+0000" }, { "id": "429165", "author": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "body": "[~hknoechel] any chance of getting your perspective on this issue?", "updateAuthor": { "name": "threethirds", "key": "threethirds", "displayName": "Anthony Chung", "active": true, "timeZone": "Australia/Sydney" }, "created": "2017-10-17T04:38:34.000+0000", "updated": "2017-10-17T04:38:34.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }