Web Browser Widget - Local HTML File on Android

I am working on using the Web Browser widget to load a local HTML file on Android. Running on Windows, both built and in editor, everything seems to work fine. However, launching the same thing to Android causes it to give me “Webpage not available”.

The HTML file I’m trying to load is inside the content directory, but not imported as an asset. Instead it is included as a non-asset directory to copy in the project’s packaging settings. In order to load the file into the Web Browser I’m using GetProjectContentDirectory, and appending the rest of the path to that.

In trying to debug this I’ve been checking all the paths, and comparing Windows and Android.

The paths on windows where everything works show:

  • ProjectDir: C:/MyGame/Content
  • Path I’m appending: /WebPages/index.html
  • Reading the URL the web widget has loaded: file:///C:/MyGame/Content/WebPages/index.html

On Android where it fails:

  • ProjectDir: …/…/…/MyGame/Content
  • Path I’m appending: /WebPages/index.html
  • Reading the URL the web widget has loaded: file:///MyGame/Content/WebPages/index.html

For some reason it looks like on Android its chopping off the “…/…/…/” parent directory part, and is therefore looking for the file in the wrong location. I’ve tried converting to an absolute path (ConverttoAbsolutePath), but it still showed the project directly with the relative “…/…/…/”.

Anyone else experienced this and have a solution?

Update:
So I was looking in to getting an absolute path on Android. It looks like this isn’t supported though. The FAndroidPlatformProcess::BaseDir() function returns an empty string (same for iOS).

In order to get this to work, it seems like either the Web Browser widget needs to support relative paths, or need to be able to get an absolute path on Android.

Well I at least found a work around.

I’m loading the html file into a FString using FFileHelper::LoadFileToString in some C++ code. Then I’m passing this FString into Web Browser Widget’s LoadString in blueprint. Not great, but I guess it works.

Update: This breaks all the images, soooooo this isn’t going to work.