flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

Is it possible to run a WebGL build on Android by loading it from localhost in a WebView?

Open limdp99 opened this issue 7 months ago • 2 comments

Is it possible to run a WebGL build on Android by loading it from localhost in a WebView?

I want to use the same WebGL build across all platforms, but when I host it on an actual web server and load it in an Android WebView, the framerate drops significantly. I’m aware part of it might be due to WebView limitations, but I’d like to test it locally to see if that improves performance. Is there a good way to do this?

limdp99 avatar Apr 21 '25 00:04 limdp99

As far as I know Unity WebGL builds need to run on a webserver.

If you make a WebGL build on desktop and try to open the index.html file directly, it's broken. But if you place it in the directory of a server running localhost it runs just fine.

The web version includes the WebGL index.html in a webview, which works because the Flutter web application is running on a server anyway.

A webview plugin on Android opening the WebGL build from local files won't work. If you can find some plugin or workaround that hosts a local server inside your app it might work, but that doesn't sound ideal.

Also even though Unity webGL runs on mobile, it has always been buggy and slow. I personally wouldn't want to create a WebGL app/game for mobile devices.

timbotimbo avatar May 21 '25 07:05 timbotimbo

I'm not currently going to modify the plugin to test this, but the plugin webview_flutter_plus mentions

webview_flutter_plus is an extension of webview_flutter. This package helps to load Local HTML, CSS and Javascript content from Assets or Strings via a local server

timbotimbo avatar Jun 05 '25 08:06 timbotimbo