Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27372] iOS : image file not loading into the webview from iPhone storage

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 8.0.0, Release 8.2.0
Fix Version/sn/a
Componentsn/a
LabelsapplicationDataDirectory, engSchedule, iOS, webview
ReporterJignesh Kasundra
AssigneeEric Merriman
Created2019-07-23T08:58:33.000+0000
Updated2020-02-27T12:38:30.000+0000

Description

On iPhone device (iOS 12.3.1) the image file is not getting loaded into webview from iPhone storage (applicationDataDirectory). It works on simulator 12.1 please check the attached sample test case

Attachments

FileDateSize
Resources.zip2019-07-23T08:56:48.000+000084316
Resources2.zip2019-08-05T10:19:19.000+000035825

Comments

  1. Vijay Singh 2019-07-23

    [~jignesh.igp] It looks duplicate of TIMOB-27159. Can you verify once with [PR](https://github.com/appcelerator/titanium_mobile/pull/10976).
  2. Jan Vennemann 2019-07-24

    It is not recommended to have local HTML and resource files in different folders. The assetsDirectory option introduced in TIMOB-27159 probably could solve this issue but you can avoid it in the first place by just having everything in the same directory. For example, copy the HTML/JS to Ti.Filesystem.applicationDataDirectory as well and change the src property in your HTML file to the correct relative path. The directory structure should look something like this based on your provided test case:
       .
       ├── index.html
       ├── index.js
       ├── jquery-1.8.3.js
       ├── downloaded_images
       │   └── test.jpg
       │   └── ...
       └── ...
       
    Then you can easily reference the images via downloaded_images/test.jpg.
  3. Jignesh Kasundra 2019-07-25

    Thanks! Jan Vennemann Our actual problem is, we have e-learning base app that have dynamic content (css , images ,js) need to present in webview which we are downloading from server and storing it into the iPhone storage (Ti.Filesystem.applicationDataDirectory) and loading it to webview. Where for webview presentation & layout we have static files (index.html, css , images , js) that we kept it under app Resource directory so the webview uses both directory. The storage directory access in webview is working fine with Titanium SDK 7.4.1 on iPhone Device (Latest iOS 12.3.1 version) but not from Titanium SDK 8.X.X updates and onwards
  4. Jan Vennemann 2019-07-31

    Yes, unfortunately that is a breaking change in 8.0.0 when we moved to WKWebView internally. The workaround from my previous comment should also be easily implemented for your use case. Just copy the relevant files from the resources directory to the data directory on first app launch or whenever you update the app. Then you will have everything in the same place and do not run into these limitations.
  5. Jignesh Kasundra 2019-08-05

    Thanks as you suggested. We have tested the workaround to place everything in one place ( html, image) but still the file is not loading into webview from applicationDataDirectory (Device) Please find the attached test example (Resources2.zip [^Resources2.zip] )
  6. Jan Vennemann 2019-08-13

    [~jignesh.igp], thanks for providing an example. The setHtml methods still seems to have some issues with resolving relative paths. [~vijaysingh], can you take a look at this? Using setHtml with the baseURL option fails to load local resources even when using the fix from TIMOB-27159.
  7. Jignesh Kasundra 2020-02-27

    Hello. is there any work-around to fix the issue ? i am not able to load local files JGP , JS ..etc under the webview from Phone Storage applicationDataDirectory checked on Release 8.3.1 but it's not working.

JSON Source