Search code examples
androidunity-game-enginehtml5-videochromium

Unity+Android tile memory limits exceeded, some content may not draw


I have a mobile Android SDK that programatically creates and displays a WebView containing an HTML5 video. The native Android version works correctly, however when I integrate the SDK into a Unity project, the WebView displays but the video does not, and the console is spammed with the tile memory limits exceeded, some content may not draw warning. I have looked at similar threads on here and the Unity forums, but they either referenced a bugfix in Chromium v77/78 or had no solution. I'm out of ideas and wondering if anyone had any experience with this issue. I'm leaning towards it being something related to how Unity works/builds apks, since it works in the native implementation. Any help is appreciated.


Solution

  • @Minebomber as suggested in my first comment android:hardwareAccelerated="true" generally fixes this type of issue in first go. But here in unity it forcibly make it false again. So again you will get same error.

    Based on the technique discussed in https://forum.unity.com/threads/android-hardwareaccelerated-is-forced-false-in-all-activities.532786/ and https://github.com/Over17/UnityAndroidManifestCallback, Assets/Plugins/Editor/UnityWebViewPostprocessBuild.cs


    Solution is that generate a jar of the android native code and import it in unity project and use it as binary file so that it doesn't gets changed.

    How to build WebViewPlugin.jar

    The following steps :

    1. Clone project https://github.com/kitylam9/unity-webview/tree/master/plugins/Android

    2. Open Terminal.app and perform the followings.

    $ export ANDROID_HOME=~/Library/Android/sdk
    $ export PATH=$PATH:~/Library/Android/sdk/platform-tools/bin:~/Library/Android/sdk/tools:~/Library/Android/sdk/tools/bin
    $ cd unity-webview/plugins/Android
    $ ./install.sh
    

    You should find unity-webview/build/Packager/Assets/Plugins/Android/WebViewPlugin.jar if successful.

    Usage:

    Web Player

    The implementation utilizes IFRAME so please put both "an_unityplayer_page.html" and "a_page_loaded_in_webview.html" should be placed on the same domain for avoiding cross-domain requests.

    Reference link