{ "id": "173599", "key": "TIMOB-27064", "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": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2019-08-01T00:38:16.000+0000", "created": "2019-05-07T16:34:02.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [ { "id": "57797", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "173608", "key": "TIMOB-27159", "fields": { "summary": "iOS: Ti.UI.WebView cannot load html files from cache", "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" } }, "priority": { "name": "Critical", "id": "1" }, "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": "2019-12-02T23:06:30.000+0000", "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" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Hello,\r\n\r\nWe are unable to load image on imaveView from nativePath on physical device but it's showing the image on lower version of SDK (7.5.2.GA) and Simulator (with latest version of SDK).\r\n\r\n*Test code:*\r\n{code}\r\nfunction DoTest() {\r\n\r\n\t//download image, then show it in a web view\r\n\r\n\t//create directory\r\n\tsDir = Ti.Filesystem.applicationDataDirectory + \"/productimages/\";\r\n\td = Ti.Filesystem.getFile(sDir);\r\n\tif (!d.exists()) {\r\n\t\td.createDirectory();\r\n\t}\r\n\r\n\tsImageName = \"Fortune-Cookie-2748_large.png\";\r\n\tsURL = \"https://boomboom.cart32.com/productimages/\" + sImageName;\r\n\r\n\tvar xhr = Titanium.Network.createHTTPClient();\r\n\txhr.onload = function() {\r\n\t\tf = Ti.Filesystem.getFile(sDir + sImageName);\r\n\t\t//write file\r\n\t\tTi.API.info('Status = ' + xhr.status);\r\n\t\tif (xhr.status == 200) {\r\n\t\t\tTi.API.info('SUCCESS - Size= ' + xhr.responseData.size + ' Downloaded image(' + sImageName + ') - Writing ' + f.nativePath);\r\n\t\t\t//write PNG file\r\n\t\t\tf.write(xhr.responseData);\r\n\t\t\tShowImageInWebView(sDir + sImageName);\r\n\t\t}\r\n\t};\r\n\r\n\txhr.onerror = function(e) {\r\n\t\tTi.API.info('Error: ' + e.error);\r\n\t};\r\n\r\n\tTi.API.info('Calling ' + sURL);\r\n\txhr.open('GET', sURL);\r\n\txhr.send();\r\n\r\n}\r\n\r\nfunction ShowImageInWebView(sImageFile) {\r\n\r\n\tvar f = Ti.Filesystem.getFile(sImageFile);\r\n\tTi.API.info('f.nativePath = ' + f.nativePath);\r\n\r\n\tsHTML = 'Image
';\r\n\r\n\tvar wv = Ti.UI.createWebView({});\r\n\twv.html = sHTML;\r\n\r\n\tvar win = Titanium.UI.createWindow({\r\n\t\ttitle : 'Test',\r\n\t\tmodal : true,\r\n\t\tbackgroundColor : '#ff0000'\r\n\t});\r\n\twin.add(wv);\r\n\twin.open();\r\n\r\n}\r\nDoTest(); \r\n{code}\r\n\r\n*Test Results on device:*\r\n{code}\r\n[INFO] : Calling https://boomboom.cart32.com/productimages/Fortune-Cookie-2748_large.png\r\n[INFO] : Status = 200\r\n[INFO] : SUCCESS - Size= 390580 Downloaded image(Fortune-Cookie-2748_large.png) - Writing file:///var/mobile/Containers/Data/Application/061D8DA1-A61B-47C8-8279-F9571E19D402/Documents/productimages/Fortune-Cookie-2748_large.png\r\n[INFO] : f.nativePath = file:///var/mobile/Containers/Data/Application/061D8DA1-A61B-47C8-8279-F9571E19D402/Documents/productimages/Fortune-Cookie-2748_large.png\r\n{code}\r\n\r\n*Test Environment:*\r\nAppcelerator Command-Line Interface, version 7.0.10\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.14.4\r\n Architecture = 64bit\r\n # CPUs = 4\r\n Memory = 8589934592\r\nNode.js\r\n Node.js Version = 8.9.1\r\n npm Version = 5.5.1\r\nTitanium CLI\r\n CLI Version = 5.1.1\r\nTitanium SDK\r\n SDK Version = 8.0.0.GA\r\n\r\nNote: I have tried it with WKWebView for 8.0.0.GA but got the same results.\r\n\r\nThanks", "attachment": [ { "id": "66596", "filename": "ios-device-screenshot.jpg", "author": { "name": "fhaque", "key": "fhaque", "displayName": "Fazlul Haque", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2019-05-07T16:30:01.000+0000", "size": 93999, "mimeType": "image/jpeg" }, { "id": "66595", "filename": "ios-simulator-screenshot.png", "author": { "name": "fhaque", "key": "fhaque", "displayName": "Fazlul Haque", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2019-05-07T16:30:02.000+0000", "size": 280371, "mimeType": "image/png" } ], "flagged": false, "summary": "iOS: Unable to load image on imaveView from nativePath on physical device", "creator": { "name": "fhaque", "key": "fhaque", "displayName": "Fazlul Haque", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "fhaque", "key": "fhaque", "displayName": "Fazlul Haque", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "8.0.0.GA, iOS nativePath, WebView", "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": 1172, "state": "closed", "name": "2019 Sprint 25", "startDate": "2019-12-02T23:08:39.644Z", "endDate": "2019-12-15T23:08:00.000Z", "completeDate": "2019-12-16T05:54:54.518Z", "originBoardId": 114 }, { "id": 1157, "state": "closed", "name": "2019 Sprint 16", "startDate": "2019-07-29T15:35:47.313Z", "endDate": "2019-08-11T15:35:00.000Z", "completeDate": "2019-08-12T07:57:02.552Z", "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": 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": 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": "448220", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~fhaque] Can you check TIMOB-26860? I think it's duplicate.\r\n\r\nProbably \r\n\r\n{code:java}\r\nwv.setHtml(sHTML, { baseURL: Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory).nativePath });\r\n{code}\r\nwill fix the problem. Thanks!\r\n", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-05-07T19:57:08.000+0000", "updated": "2019-05-07T19:57:08.000+0000" }, { "id": "448492", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It's bug due to WKWebView. It is similar to native issue as discussed [here|https://apple-dev.groups.io/g/cocoa/topic/wkwebview_does_not_load/6097137?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,6097137]. I'll check on this. \r\n\r\nBut following workaround will work - \r\n\r\n1.Use encoded image data while creating html instead image path. \r\n{code:java}\r\n function DoTest() {\r\n \r\n //download image, then show it in a web view\r\n \r\n //create directory\r\n sDir = Ti.Filesystem.applicationDataDirectory + \"/productimages/\";\r\n d = Ti.Filesystem.getFile(sDir);\r\n if (!d.exists()) {\r\n d.createDirectory();\r\n }\r\n \r\n sImageName = \"Fortune-Cookie-2748_large.png\";\r\n sURL = \"https://boomboom.cart32.com/productimages/\" + sImageName;\r\n \r\n var xhr = Titanium.Network.createHTTPClient();\r\n xhr.onload = function() {\r\n f = Ti.Filesystem.getFile(sDir + sImageName);\r\n //write file\r\n Ti.API.info('Status = ' + xhr.status);\r\n if (xhr.status == 200) {\r\n Ti.API.info('SUCCESS - Size= ' + xhr.responseData.size + ' Downloaded image(' + sImageName + ') - Writing ' + f.nativePath);\r\n //write PNG file\r\n f.write(xhr.responseData);\r\n ShowImageInWebView(sDir + sImageName);\r\n }\r\n };\r\n \r\n xhr.onerror = function(e) {\r\n Ti.API.info('Error: ' + e.error);\r\n };\r\n \r\n Ti.API.info('Calling ' + sURL);\r\n xhr.open('GET', sURL);\r\n xhr.send();\r\n \r\n}\r\n \r\nfunction ShowImageInWebView(sImageFile) {\r\n \r\n var f = Ti.Filesystem.getFile(sImageFile);\r\n Ti.API.info('f.nativePath = ' + f.nativePath);\r\n \r\n // Add following 3 lines in your code\r\n var encodedData = Ti.Utils.base64encode(f);\r\n var imageForTheHtml = \"data:application/png;base64,\" + encodedData;\r\n sHTML = 'Image
';\r\n\r\n // sHTML = 'Image
';\r\n\r\n var wv = Ti.UI.createWebView({});\r\n wv.html = sHTML;\r\n \r\n var win = Titanium.UI.createWindow({\r\n title : 'Test',\r\n modal : true,\r\n backgroundColor : '#ff0000'\r\n });\r\n win.add(wv);\r\n win.open();\r\n}\r\nDoTest(); \r\n\r\n{code}\r\n\r\n2. If it is possible to give web url, it will also work -\r\n\r\n\r\n{code:java}\r\n var sHTML = 'Image
';\r\n\r\n var wv = Ti.UI.createWebView({});\r\n wv.html = sHTML;\r\n \r\n var win = Titanium.UI.createWindow({\r\n title : 'Test',\r\n modal : true,\r\n backgroundColor : '#ff0000'\r\n });\r\n win.add(wv);\r\n win.open();\r\n{code}\r\n\r\n ", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-05-17T21:49:54.000+0000", "updated": "2019-05-17T21:50:31.000+0000" }, { "id": "450202", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This issue has been fixed in TIMOB-27159, which is planned for 8.2.0. Still a minor modification will require in test code. See following example-\r\n\r\n{code:java}\r\nfunction DoTest() {\r\n \r\n //download image, then show it in a web view\r\n \r\n //create directory\r\n sDir = Ti.Filesystem.applicationDataDirectory + \"/productimages/\";\r\n d = Ti.Filesystem.getFile(sDir);\r\n if (!d.exists()) {\r\n d.createDirectory();\r\n }\r\n \r\n sImageName = \"Fortune-Cookie-2748_large.png\";\r\n sURL = \"https://boomboom.cart32.com/productimages/\" + sImageName;\r\n \r\n var xhr = Titanium.Network.createHTTPClient();\r\n xhr.onload = function() {\r\n f = Ti.Filesystem.getFile(sDir + sImageName);\r\n //write file\r\n Ti.API.info('Status = ' + xhr.status);\r\n if (xhr.status == 200) {\r\n Ti.API.info('SUCCESS - Size= ' + xhr.responseData.size + ' Downloaded image(' + sImageName + ') - Writing ' + f.nativePath);\r\n //write PNG file\r\n f.write(xhr.responseData);\r\n ShowImageInWebView(sDir + sImageName);\r\n }\r\n };\r\n \r\n xhr.onerror = function(e) {\r\n Ti.API.info('Error: ' + e.error);\r\n };\r\n \r\n Ti.API.info('Calling ' + sURL);\r\n xhr.open('GET', sURL);\r\n xhr.send();\r\n \r\n}\r\n \r\nfunction ShowImageInWebView(sImageFile) {\r\n \r\n var f = Ti.Filesystem.getFile(sImageFile);\r\n Ti.API.info('f.nativePath = ' + f.nativePath);\r\n \r\n sHTML = 'Image
';\r\n \r\n //create directory for writing html\r\n var htmlDir = Ti.Filesystem.applicationDataDirectory + \"/html/\";\r\n var d = Ti.Filesystem.getFile(htmlDir);\r\n if (!d.exists()) {\r\n d.createDirectory();\r\n }\r\n var htmlFile = Ti.Filesystem.getFile(htmlDir + 'sHTML.html');\r\n htmlFile.write(sHTML);\r\n\r\n var appDataDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory);\r\n\r\n \r\n var wv = Ti.UI.createWebView({\r\n url: htmlFile.nativePath,\r\n assetsDirectory: appDataDir.nativePath\r\n });\r\n \r\n \r\n var win = Titanium.UI.createWindow({\r\n title : 'Test',\r\n modal : true,\r\n backgroundColor : '#ff0000'\r\n });\r\n win.add(wv);\r\n win.open();\r\n \r\n}\r\nDoTest(); \r\n{code}", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-08-01T00:34:56.000+0000", "updated": "2019-08-01T00:35:51.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }