Xamarin.forms: [Bug] <img> in webview works on iOS Simulator and fails on iOS device for local files

Created on 20 Feb 2020  路  6Comments  路  Source: xamarin/Xamarin.Forms

Description

A local webview referring to an image downloaded to the app at runtime won't load in an iOS device but will load in the iOS Simulator, Android emulator and Android devices

I am downloading images and storing them in the apps folder here
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

Steps to Reproduce

I've made a simple example project, Its using Forms 4.4.0.991640

Run as is on Android for emulator and devices
Run as is for iOS Simulator
Add a valid bundle identifier and run on iOS device

Expected Behavior

iOS webview can load local files with explicit referencing
Additionally I should be able to specify BaseUrl as the local folder and use relative paths for files

Actual Behavior

iOS devices in webview fail to load local files

Basic Information

  • Version with issue:4.4.0.991640
  • Last known good version: not sure
  • IDE: VS for Mac 8.4.6 (36)
  • Platform Target Frameworks:

    • OS: Xcode 11.3.1 Xamarin.iOS 13.10.0.17

    • Xamarin.Android: 10.1.3.7

Screenshots

In the following two screenshots from Android the emulator and the physical device both can load fully defined paths, files from the assets folder and an image from an online source, they cannot load the relative file from the apps library folder or a manifest file

Android Emulator | Pixel 2 real device
:-------------------------:|:-------------------------:
|

In the following two screenshots from iOS the Simulator can load fully defined paths, files from the resources folder and an image from an online source, the real iPad device cannot load the full defined path image but can load the others

iOS Simulator | iPad real device
:-------------------------:|:-------------------------:
|

Reproduction Link

Sample project showing multiple ways of loading images into a webview
https://github.com/duindain/xamarin_ios_webview_issue

Workaround

I'm just using external urls in the webview for now on iOS instead of downloading images and having them cached for the future

4.4.0 webview regression iOS 馃崕 bug

Most helpful comment

Is there any further progress on this?

All 6 comments

A previous bug i submitted to the PDF.js project has a working version of loading local files into a Forms webview in Xamarin Forms 4.1.0.555618 here

This no longer works in Xamarin Forms 4.4.0.991640

We use legacy platform specific webviews as well in our app and that loads local resources with full paths from the same folder in this bug Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) fine in Xamarin forms project v4.4.0.991640 so this issue seems specific to the Xamarin implementation in iOS of webview

When using complex local files using JavaScript, I the local page does not load. Simple HTML string text does load.

This has been a problem on iOS (12.4.5 or older - 13.x.x seems to work fine) only since 4.4 of Xamarin Forms.

I hope this gets fixed soon. It is a fairly basic need and does not currently work properly.

Is there any further progress on this?

Any update on this? I'm seeing the same issue on Xamarin forms 4.7. I'm storing downloaded files in FileSystem.CacheDirectory.

The appear correctly on device in iOS 13 but not on iOS 12.

They do appear correctly in iOS 12.4 and 11.4 simulators.

Have been this planned to be fixed soon for IOS 12.x.x?

Was this page helpful?
0 / 5 - 0 ratings