Webview Bug workaround for Gif images


It seems offline html files that contains gif is possible to be shown in webview. However, it seems there is a bug that failed to show the images unless load the gif images one by one alone in the webview before opening the htm file that contains them. Here is my workaround:

If Button1 is not clicked before clicking button2, all the images is not shown. However if button1 clicked then all images will be shown even after closing the app and opening the app again without clicking button1 before button2.

Here is the app:

At least now I know why this happens.
It seems that the current path of the offline html file is:
during development:

after compile to .apk:

which is obvious that it is not the android asset path. So if the image has not been cached into the cache by loading it at least once, then the html file would not find it, because the images’ path are the relative path at the same path of the html file.

1 Like

I think the solution is to use BaseUrl and html advanced settings of the webview. However, that seems does not load the html at all. I have used loadDataWithBaseURL() method in Android studio before without issues, but in Thunkable seems I am missing something or it has not been implemented yet.

Update 2:
Seems that this is indeed a bug in Thunkable X. I have tested the same html file and images on MIT App inventor and it works without issue. No need to assign baseUrl since by default it should point the path to where the html is, which is the android asset folder and not the cache.

1 Like