ionic-team / ionic-team/cordova-plugin-ionic-webview

Rare problems loading local images in the webview, url is correct, and file exists

Open
#482 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
493
Forks
410
PR merge metrics
No merged PRs in 30d

Description

Im having a hard time trying to eliminate this bug.

We have an app thats in production, it works online an offline, so we download any images that are needed, and display them using the built-in normalize url feature in the ionic wkwebview. For reasons, we have an onload handler, to detect image size, our code looks something like this.
```javascript
let img = new Image();
img.onload = () => {
//get image size code
}

img.onerror = (onError) => {
//this should not be happening!!
//we actually use window.resolveLocalFileSystemURL, create a fileobject,
//and then check the filesize, to see if the image exist at the provided url...
//it does.

img.src = window.Ionic.WebView.convertFileSrc(url)
```
This works mostly, but we use error reporting and a semi large amount of users, get failed loads from time to time, only using WKWebview on iOS.

Any good ideas to debug this edgecase?

As it works almost always, we are having a hard time reproducing it locally.

Almost forgot, when we get the Error, the error event only includes:
`{ isTrusted: true }`

Indicating, its from a different domain. However, both the image and the code, should be served from:
`localhost:8080`
So we should be getting the full event, shouldnt we?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.