{ "id": "173608", "key": "TIMOB-27159", "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": "20033", "name": "Release 9.0.0", "archived": false, "released": true, "releaseDate": "2020-03-18" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2020-01-30T21:11:45.000+0000", "created": "2019-05-09T09:18:49.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "8.0.0", "engSchedule", "ios", "webview" ], "versions": [ { "id": "19882", "name": "Release 8.0.0", "archived": false, "released": true, "releaseDate": "2019-03-14" } ], "issuelinks": [ { "id": "57797", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "173599", "key": "TIMOB-27064", "fields": { "summary": "iOS: Unable to load image on imaveView from nativePath on physical device", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "None", "id": "6" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-01-30T21:11:45.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": "*Note: Issue can be reproduced only on device, webview works as expected on simulator*\r\nNew WebView fails to load html files stored in the app with the error:\r\n\r\n{code:java}\r\ndefault\t11:34:49.407006 +0300\tcom.apple.WebKit.Networking\t0x1075e8000 - NetworkResourceLoader::startNetworkLoad: (pageID = 5, frameID = 1, resourceID = 1, isMainResource = 1, isSynchronous = 0)\r\ndefault\t11:34:49.407054 +0300\tcom.apple.WebKit.Networking\tTask <0AF948FB-871A-4EDD-A632-D67CBB10B3BC>.<1> resuming, QOS(0x19)\r\ndefault\t11:34:49.407103 +0300\tcom.apple.WebKit.Networking\t[Telemetry]: Activity on Task <0AF948FB-871A-4EDD-A632-D67CBB10B3BC>.<1> was not selected for reporting\r\nerror\t11:34:49.407332 +0300\tkernel\tSandbox: com.apple.WebKit(10340) deny(1) file-read-data /private/var/mobile/Containers/Data/Application/B7D5C2EF-634E-4F7E-A7EC-BAB4DDF48868/Library/Caches/307/platform_article_1112110663/article.html\r\ndefault\t11:34:49.407402 +0300\tcom.apple.WebKit.Networking\t0x1075e8000 - NetworkResourceLoader::startNetworkLoad: (pageID = 5, frameID = 1, resourceID = 1, description = LocalDataTask <0AF948FB-871A-4EDD-A632-D67CBB10B3BC>.<1>)\r\nerror\t11:34:49.407557 +0300\tcom.apple.WebKit.Networking\tTask <0AF948FB-871A-4EDD-A632-D67CBB10B3BC>.<1> finished with error - code: 1\r\nerror\t11:34:49.407608 +0300\tcom.apple.WebKit.Networking\tTask <0AF948FB-871A-4EDD-A632-D67CBB10B3BC>.<1> load failed with error Error Domain=kCFErrorDomainCFNetwork Code=1 UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=, _NSURLErrorFailingURLSessionTaskErrorKey=} [1]\r\ndefault\t11:34:49.408142 +0300\tcom.apple.WebKit.Networking\t0x1075e8000 - NetworkResourceLoader::didFailLoading: (pageID = 5, frameID = 1, resourceID = 1, isTimeout = 0, isCancellation = 0, isAccessControl = 0, errCode = 1)\r\n{code}\r\n\r\nReading iOS documentation I noticed that local files should be loaded using *loadFileURL* method as in https://github.com/appcelerator-modules/Ti.WKWebView/blob/master/ios/Classes/TiWkwebviewWebView.m#L198 but I don't see that in https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIWebView.m#L664\r\n", "attachment": [ { "id": "66679", "filename": "Resources.zip", "author": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-06-10T13:03:35.000+0000", "size": 2259, "mimeType": "application/zip" } ], "flagged": false, "summary": "iOS: Ti.UI.WebView cannot load html files from cache", "creator": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Ti 8.0.0.GA iOS", "closedSprints": [ { "id": 1169, "state": "closed", "name": "2019 Sprint 22", "startDate": "2019-10-21T15:38:21.747Z", "endDate": "2019-11-03T15:38:00.000Z", "completeDate": "2019-11-04T18:36:57.022Z", "originBoardId": 114 }, { "id": 1170, "state": "closed", "name": "2019 Sprint 23", "startDate": "2019-11-04T18:38:14.526Z", "endDate": "2019-11-17T18:38:00.000Z", "completeDate": "2019-11-18T16:38:18.423Z", "originBoardId": 114 }, { "id": 1171, "state": "closed", "name": "2019 Sprint 24", "startDate": "2019-11-18T16:40:09.114Z", "endDate": "2019-12-01T16:40:00.000Z", "completeDate": "2019-12-02T23:06:24.654Z", "originBoardId": 114 }, { "id": 1160, "state": "closed", "name": "2019 Sprint 17", "startDate": "2019-08-12T07:59:28.950Z", "endDate": "2019-08-25T07:59:00.000Z", "completeDate": "2019-08-26T15:35:29.980Z", "originBoardId": 114 }, { "id": 1176, "state": "closed", "name": "2020 Sprint 1", "startDate": "2020-01-02T21:15:56.301Z", "endDate": "2020-01-17T21:15:00.000Z", "completeDate": "2020-01-21T17:44:29.577Z", "originBoardId": 114 }, { "id": 1161, "state": "closed", "name": "2019 Sprint 18", "startDate": "2019-08-26T21:46:26.269Z", "endDate": "2019-09-08T21:46:00.000Z", "completeDate": "2019-09-09T20:39:58.761Z", "originBoardId": 114 }, { "id": 1177, "state": "closed", "name": "2020 Sprint 2", "startDate": "2020-01-20T17:44:37.733Z", "endDate": "2020-01-31T17:44:00.000Z", "completeDate": "2020-01-31T16:57:44.689Z", "originBoardId": 114 }, { "id": 1163, "state": "closed", "name": "2019 Sprint 19", "startDate": "2019-09-09T20:43:13.091Z", "endDate": "2019-09-22T20:43:00.000Z", "completeDate": "2019-09-23T15:37:35.874Z", "originBoardId": 114 }, { "id": 1165, "state": "closed", "name": "2019 Sprint 20", "startDate": "2019-09-23T15:38:43.949Z", "endDate": "2019-10-06T15:38:00.000Z", "completeDate": "2019-10-07T18:33:11.953Z", "originBoardId": 114 }, { "id": 1168, "state": "closed", "name": "2019 Sprint 21", "startDate": "2019-10-07T18:35:57.052Z", "endDate": "2019-10-20T18:35:00.000Z", "completeDate": "2019-10-21T15:38:00.182Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "448756", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~nipoul] Can you give a test case for mentioned issue? Thanks!", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-05-31T20:48:51.000+0000", "updated": "2019-05-31T20:48:51.000+0000" }, { "id": "448951", "author": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi,\r\n\r\nSorry for the delay, I uploaded a test case. It turns out issue exists when trying to access a file stored in app's Cache directory. As you can see I have 3 cases:\r\n\r\n\r\n{code:java}\r\n//All OK\r\n//webView.url = fileInResources.nativePath;\r\n\r\n//Does not work at all on device\r\nwebView.url = fileInCache.nativePath;\r\n\r\n//works but no css on device\r\n// webView.setHtml(htmlInCache.read(), {\r\n// \tbaseURL: cacheDir.nativePath\r\n// });\r\n{code}\r\n\r\nWhen html and css file are on resources everything is ok, setting url to a path under Cache fails, and setHtml using file.read from cache works but again css fails to load. Again the only workaround working is using setHtml and referring to css by absolute path in resources.\r\n\r\nIs this an iOS restriction? Is there any workaround to have html in cache and use relative paths for css files?\r\nI tried using the code below in the SDK and it works but again allowingReadAccessToURL is fixed so it's not proper solution, ideally it would be set similarly to baseURL param in setHtml\r\n\r\n{code:java}\r\n [[self webView] loadFileURL:[NSURL fileURLWithPath:path]\r\n allowingReadAccessToURL:[NSURL fileURLWithPath:[[[path stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]];\r\n{code}\r\n\r\nThank you in advance\r\n", "updateAuthor": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-06-10T13:03:38.000+0000", "updated": "2019-06-10T13:03:38.000+0000" }, { "id": "449142", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks for test case [~nipoul]. Webkit has restricted more on local file loading via WKWebView. Apple has given new API in WKWebView as mentioned in above comment [- (WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL|https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl?language=objc]. \r\nI think we should expose new API for local file Urls-\r\n\r\nsetFileUrl({\r\nurl: \"local file url\",\r\nreadAccessUrl: \"read access file url\"\r\n})\r\n\r\n[~jquick] What you think? \r\nThanks!", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-06-18T00:22:15.000+0000", "updated": "2019-06-18T00:22:15.000+0000" }, { "id": "449143", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~vijaysingh], this sounds like a security feature on Apple's end. Particularly for MacOS where they don't want some rogue local HTML file having full filesystem access via a file:// scheme... and iOS inherited it.\r\n\r\nAndroid's {{WebView}} doesn't have an equivalent to the {{allowingReadAccessToURL}} API.\r\n\r\nDo we need to add a new API? What if we were to automatically assign the {{allowingReadAccessToURL}} to the given HTML file's directory path?", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-06-18T01:20:24.000+0000", "updated": "2019-06-18T01:20:24.000+0000" }, { "id": "449145", "author": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "body": "If possible It would be nice to be able to set allowingReadAccessToURL actually, so that assets like css files can be shared between files in cache using relative paths", "updateAuthor": { "name": "nipoul", "key": "nipoul", "displayName": "Nikos Poulios", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-06-18T07:36:48.000+0000", "updated": "2019-06-18T07:36:48.000+0000" }, { "id": "449175", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "https://github.com/appcelerator/titanium_mobile/pull/10976\r\n\r\nTest Case - \r\n\r\n{code:java}\r\n(function() {\r\n var window = Ti.UI.createWindow();\r\n \r\n var createDirectory = function(f) {\r\n if(f && !f.exists()) {\r\n f.createDirectory();\r\n }\r\n \r\n return f; \r\n };\r\n \r\n //Copy from Resources to cache folder\r\n var cacheDir = createDirectory(Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory));\r\n var htmlDir = createDirectory(Ti.Filesystem.getFile(cacheDir.nativePath, 'html'));\r\n var cssDir = createDirectory(Ti.Filesystem.getFile(cacheDir.nativePath, 'css'));\r\n var resourceDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory);\r\n\r\n var htmlFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'html', 'example.html');\r\n var cssFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'css', 'test.css');\r\n \r\n var htmlInCache = Ti.Filesystem.getFile(cacheDir.nativePath, 'html', 'example.html'); \r\n var cssInCache = Ti.Filesystem.getFile(cacheDir.nativePath, 'css', 'test.css');\r\n \r\n htmlFile.copy(htmlInCache.nativePath);\r\n cssFile.copy(cssInCache.nativePath);\r\n \r\n var fileInResources = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'html', 'example.html');\r\n \r\n var webView = Ti.UI.createWebView({\r\n width: Ti.UI.FILL,\r\n height: Ti.UI.FILL,\r\n url: htmlInCache.nativePath,\r\n assetsDirectory: cacheDir.nativePath\r\n });\r\n \r\n\r\n window.add(webView);\r\n window.open();\r\n})();\r\n{code}\r\n", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-06-18T18:31:47.000+0000", "updated": "2019-07-02T19:10:21.000+0000" }, { "id": "450281", "author": { "name": "kmahalingam", "key": "kmahalingam", "displayName": "Keerthi Mahalingam", "active": false, "timeZone": "America/Los_Angeles" }, "body": "FR passed.please provide PR for 8_3_X", "updateAuthor": { "name": "kmahalingam", "key": "kmahalingam", "displayName": "Keerthi Mahalingam", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2019-08-05T18:04:45.000+0000", "updated": "2019-08-15T18:49:53.000+0000" }, { "id": "450968", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "While the FR may have passed, the unit tests for WebView are repeatedly failing for this PR. As such, I've bumped that back to failed QE/review. 4 WebView tests are timing out on this PR, and have been after several builds on Jenkins.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2019-08-29T19:58:45.000+0000", "updated": "2019-08-29T19:58:45.000+0000" }, { "id": "451009", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It looks like iOS 13 broken WKWebView's API - (nullable WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL. See discussion https://forums.developer.apple.com/thread/120566\r\nIn iOS 12 it is working fine.", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-08-30T21:55:32.000+0000", "updated": "2019-08-30T21:55:32.000+0000" }, { "id": "453680", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR - https://github.com/appcelerator/titanium_mobile/pull/11431", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-01-14T00:37:50.000+0000", "updated": "2020-01-14T00:37:50.000+0000" }, { "id": "453780", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed, Waiting on Jenkins build", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-01-23T10:09:11.000+0000", "updated": "2020-01-23T10:09:11.000+0000" }, { "id": "453785", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "merged to master for 9.0.0", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2020-01-23T15:07:14.000+0000", "updated": "2020-01-23T15:07:14.000+0000" }, { "id": "453950", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix with SDK 9.0.0.v20200130075800.\r\nClosing.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-01-30T21:11:41.000+0000", "updated": "2020-01-30T21:11:41.000+0000" } ], "maxResults": 18, "total": 18, "startAt": 0 } } }