Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UnityAds WebViewApp.java is throwing OutOfMemoryError and crashing my game

Discussion in 'Unity Ads & User Acquisition' started by vitaliano_fanatee, Jan 18, 2021.

  1. vitaliano_fanatee

    vitaliano_fanatee

    Joined:
    Oct 9, 2020
    Posts:
    37
    Hi folks, I'm having some issues with the UnityAds SDK, the class WebViewApp is throwing a java.lang.OutOfMemoryError from 3 different lines 120, 130 and 131, highlighted below:
    upload_2021-1-18_19-54-3.png
    You can also check the full code here.

    And below you also can check the crash logs captured by Crashlytics:
    upload_2021-1-18_19-54-22.png
    upload_2021-1-18_19-54-40.png
    upload_2021-1-18_19-54-59.png

    Do you guys have any idea if I can mitigate this issue from my side? Or do I have to wait for an UnityAds SDK new version to fix this issue?
     
  2. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    Which version of the Ads SDK are you using? Are you seeing this error on multiple devices or are you using a specific device?
     
  3. vitaliano_fanatee

    vitaliano_fanatee

    Joined:
    Oct 9, 2020
    Posts:
    37
    I'm using the UnityAds version 3.5.1 (https://github.com/Unity-Technologies/unity-ads-android/releases/tag/3.5.1) on Android, the game is targeting the Android API 29 and below you can check the range of device models:
    • LG Stylus3
    • moto g(8) play
    • LG K40S
    • Galaxy A10
    • Galaxy Tab A
    • Galaxy J3(2017)
    • LG Stylo 6
    • Galaxy J5(2016)
    • moto g(7) play
    • LG K9
    • Galaxy Grand Prime Plus
    • Galaxy Tab A 8.0
    • moto g fast
    • moto e
    • Galaxy Tab E 9.6
    • LG LM-X525
    • LG Stylo 3 Plus
    • LG K8(2018)
    • Galaxy J2
    • LG Aristo 4+
    • HTC Desire 650
    • Galaxy S5 Neo
    Maybe, changing the line 119 from this
    private void invokeJavascriptMethod(String className, String methodName, JSONArray params) throws JSONException {
    to this
    private void invokeJavascriptMethod(String className, String methodName, JSONArray params) throws JSONException, OutOfMemoryError {
    , will hold the exception inside the try/catch here and solve the issue?
     
  4. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    From looking at the specs of those devices they all seem to be fairly low power. Most of them have <2gb ram. From the logs you posted the issue simply seems to be that those devices are actually out of memory, and therefore the Ads SDK isn't able to allocate the memory it needs to perform correctly.

    We have seen this error before and typically the issue is due to the developer's app using too much memory and not leaving enough for the Ads SDK. I would recommend trying to update to the latest version of our SDK and if that fails, you might have some success addressing your app's overall memory usage.
     
  5. hexdecc

    hexdecc

    Joined:
    Oct 24, 2014
    Posts:
    141

    I receive this error on iPhoneX while watching Unity ADS but not on iPad
     
  6. harish_unity290

    harish_unity290

    Joined:
    Feb 16, 2022
    Posts:
    1
    @vitaliano_fanatee we are also getting this crash with unity ads disabled , is there any fix for this ?