{ "id": "165117", "key": "TIMOB-24259", "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": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-12-28T19:57:26.000+0000", "created": "2016-12-24T11:46:26.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "community", "ios", "local", "notable", "webview" ], "versions": [ { "id": "18154", "name": "Release 6.0.1", "archived": false, "released": true, "releaseDate": "2016-12-21" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-01-20T22:32:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Yes, I know that this is an extreme case, but it happened to us (me and @Jei).\r\n\r\nWhen you try to load multiple (1+) webviews at the same time with *same local URL*, the listeners provided by the XHR bridge (ti-injection) works *only for the first one instantiated*.\r\n\r\nI debugged for hours, and finally realized why this happens.\r\n\r\nThe _LocalProtocolHandler_ class implemented in the Webview communication receives only the first URL to load; and this causes only one injection *with the same Ti.pageToken*.\r\n\r\nIn this screenshot you can see that the generated pageToken is the same:\r\n\r\n!https://cl.ly/3H393n3C2a2D/Screen%20Shot%202016-12-24%20at%2012.29.07.png!\r\n\r\nThe solution would be to inject a new header that has a unique counter thats incremented every time a new local URL is set.", "attachment": [ { "id": "61301", "filename": "file.html", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-01-20T19:47:11.000+0000", "size": 369, "mimeType": "text/html" } ], "flagged": false, "summary": "iOS: Multiple Webviews with same local URL does not inject Titanium XHR bridge properly", "creator": { "name": "kopiro", "key": "kopiro", "displayName": "Flavio De Stefano", "active": true, "timeZone": "Europe/Rome" }, "subtasks": [], "reporter": { "name": "kopiro", "key": "kopiro", "displayName": "Flavio De Stefano", "active": true, "timeZone": "Europe/Rome" }, "environment": null, "closedSprints": [ { "id": 784, "state": "closed", "name": "2016 Sprint 26 SDK", "startDate": "2016-12-17T01:24:57.928Z", "endDate": "2016-12-31T01:24:00.000Z", "completeDate": "2017-01-03T02:15:01.548Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "403893", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Community PR: https://github.com/appcelerator/titanium_mobile/pull/8712\r\n\r\nTest-Case:\r\n{code:js}\r\nvar w = Ti.UI.createWindow();\r\nvar i = 0;\r\n \r\nvar a1 = Ti.UI.createWebView({ url: \"file.html\", borderColor: \"#000\", borderWidth: 1, left: 0, top: 0, width: \"50%\", height: \"50%\" });\r\nvar a2 = Ti.UI.createWebView({ url: \"file.html\", borderColor: \"#000\", borderWidth: 1, right: 0, top: 0, width: \"50%\", height: \"50%\" });\r\nvar a3 = Ti.UI.createWebView({ url: \"file.html\", borderColor: \"#000\", borderWidth: 1, left: 0, bottom: 0, width: \"50%\", height: \"50%\" });\r\nvar a4 = Ti.UI.createWebView({ url: \"file.html\", borderColor: \"#000\", borderWidth: 1, right: 0, bottom: 0, width: \"50%\", height: \"50%\" });\r\n \r\nw.add(a1);\r\nw.add(a2);\r\nw.add(a3);\r\nw.add(a4);\r\n \r\nfunction onLoad() {\r\n // should be \"FEFIFO-4\" after the first load and \"FEFIFO-5\" after clicking the first web view\r\n Ti.App.fireEvent('test', { text: 'FEFIFO-' + (++i) }); \r\n}\r\n\r\nfunction reload(e) {\r\n e.source.reload();\r\n} \r\n \r\na1.addEventListener('load', onLoad);\r\na2.addEventListener('load', onLoad);\r\na3.addEventListener('load', onLoad);\r\na4.addEventListener('load', onLoad);\r\n\r\na1.addEventListener('click', reload);\r\na2.addEventListener('click', reload);\r\na3.addEventListener('click', reload);\r\na4.addEventListener('click', reload);\r\n \r\nw.open();\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-12-28T14:37:22.000+0000", "updated": "2016-12-28T19:58:27.000+0000" }, { "id": "404990", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Using the sample code above with the attached HTML file I verified that the page token was unique for each instance of the web view and that all event listeners fired on all web views. \r\nTested on;\r\niPhone 7 (10.2) and Simulator (10.2)\r\nMacOS 10.11.6 (15G31)\r\nStudio 4.8.1.201612050850\r\nTi SDK 6.1.0.v20170118152304\r\nAppc NPM 4.2.8\r\nAppc CLI 6.1.0\r\nTi CLI 5.0.11\r\nAlloy 1.9.5\r\nArrow 1.10.1\r\nXcode 8.2 (8C38)\r\nNode v4.6.0\r\nJava 1.7.0_80", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-01-20T22:32:02.000+0000", "updated": "2017-01-20T22:32:02.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }