Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

JNI ERROR (app bug): global reference table overflow // Please find the cause.

Discussion in 'Editor & General Support' started by Dreamidea2017, Sep 7, 2020.

  1. Dreamidea2017

    Dreamidea2017

    Joined:
    Feb 1, 2019
    Posts:
    6
    error :
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] JNI ERROR (app bug): global reference table overflow (max=51200)global reference table dump:
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] Last 10 entries (of 51200):
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51199: 0x6f901170 java.lang.Class<android.app.ApplicationPackageManager>
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51198: 0x1351afb8 android.app.ApplicationPackageManager
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51197: 0x1351aff8 java.lang.Class<com.google.firebase.MessagingUnityPlayerActivity>
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51196: 0x13519a78 com.google.firebase.MessagingUnityPlayerActivity
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51195: 0x134fd1e0 java.lang.Class<com.unity3d.player.UnityPlayer>
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51194: 0x6f901170 java.lang.Class<android.app.ApplicationPackageManager>
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51193: 0x1351afb8 android.app.ApplicationPackageManager
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51192: 0x1351aff8 java.lang.Class<com.google.firebase.MessagingUnityPlayerActivity>
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51191: 0x13519a78 com.google.firebase.MessagingUnityPlayerActivity
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 51190: 0x134fd1e0 java.lang.Class<com.unity3d.player.UnityPlayer>
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] Summary:
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 30473 of java.lang.Class (344 unique instances)
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 10012 of com.google.firebase.MessagingUnityPlayerActivity (1 unique instances)
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 10008 of android.app.ApplicationPackageManager (1 unique instances)
    06-19 18:54:20.061 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 592 of java.nio.DirectByteBuffer (592 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 18 of java.lang.String (18 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 4 of dalvik.system.PathClassLoader (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 4 of java.lang.ref.WeakReference (4 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 4 of android.database.ContentObserver$Transport (4 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 3 of android.opengl.EGLSurface (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 3 of android.opengl.EGLContext (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 3 of android.opengl.EGLDisplay (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 3 of com.google.android.gms.common.internal.BaseGmsClient$zzd (3 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 3 of android.app.LoadedApk$ReceiverDispatcher$InnerReceiver (3 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 3 of android.app.LoadedApk$ServiceDispatcher$InnerConnection (3 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 2 of android.hardware.display.DisplayManager (1 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 2 of $Proxy3 (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 2 of java.lang.ThreadGroup (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 2 of dalvik.system.DexClassLoader (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 2 of android.os.Handler (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 2 of android.app.LoadedApk$ServiceDispatcher$DeathMonitor (2 unique instances)
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.auth.api.signin.GoogleSignInAccount
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.internal.zzq
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.unity.purchasing.googleplay.GooglePlayPurchasing
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.unity3d.player.UnityPlayer
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.games.bridge.InvitationCallbackProxy
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy9
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy8
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy7
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy6
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy5
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy4
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy2
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy1
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of $Proxy0
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.unity3d.player.Camera2Wrapper
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of java.lang.Object
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of dalvik.system.VMRuntime
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.media.MediaRouter
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.media.AudioManager
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.os.Bundle
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.Choreographer
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.hardware.input.InputManager
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.util.DisplayMetrics
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.SurfaceView
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.app.ActivityThread$ApplicationThread
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.os.Binder
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.os.HandlerThread
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.WindowManagerGlobal$1
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.content.ContentProvider$Transport
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.KeyCharacterMap
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.telephony.PhoneStateListener$IPhoneStateListenerStub
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.Display
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.media.MediaRouter$Static$1
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.app.SharedPreferencesImpl
    06-19 18:54:20.062 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.ViewRootImpl$W
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.hardware.display.DisplayManagerGlobal$DisplayManagerCallback
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.location.LocationManager
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.accessibility.AccessibilityManager$1
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.os.PersistableBundle$1
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.hardware.input.InputManager$InputDevicesChangedListener
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.app.SharedPreferencesImpl$EditorImpl
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.os.Handler$MessengerImpl
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.inputmethod.InputMethodManager$1
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.view.autofill.AutofillManager$AutofillManagerClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of android.media.MediaRouter$Static$Client
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.InvitationsClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.firebase.FirebaseApp
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.firebase.messaging.FirebaseMessaging
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.VideosClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.EventsClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.TurnBasedMultiplayerClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.SnapshotsClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.google.android.gms.games.RealTimeMultiplayerClient
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666] 1 of com.unity3d.player.HFPStatus
    06-19 18:54:20.063 12614 13265 F c.LegendOfAstr: java_vm_ext.cc:666]
    06-19 18:54:20.196 12614 13265 F c.LegendOfAstr: runtime.cc:641] Runtime aborting...

    After building with apk in Unity, there is a problem that the app terminates with the error in mobile environment. If you stand still after running the app, it does not end after a certain period of time. Tinggi is irregular for about 10 minutes to 3 days.

    There is no place to use AndroidJavaClass, AndroidJavaObject or AndroidJNI inside. There is only one to receive information from that Android device

    AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject>("currentActivity");
    AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject>("getContentResolver");
    AndroidJavaClass secure = new AndroidJavaClass("android.provider.Settings$Secure");
    string android_id = secure.CallStatic<string>("getString", contentResolver, "android_id");

    Code.

    I've been wandering for months. I want to help.
     
  2. Dreamidea2017

    Dreamidea2017

    Joined:
    Feb 1, 2019
    Posts:
    6
    I solved the problem. I could not confirm the cause of the problem, but updating the version from Unity 19.4.0 to 19.4.10 solved the problem.
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    If you use AndroidJavaObject or AndroidJavaClass, you should call Dispose() on them (or wrap then in using block) as soon as you don't need them anymore. Otherwise you rely on garbage collector and risk running out of Java global references.
     
  4. srybi

    srybi

    Joined:
    Apr 10, 2022
    Posts:
    1
    Hey AC!
    I face the same error.. We're building an AR-App using the Sceneform SDK. We're rendering a bunch of Shapes and after ~2000 the application crashes with the error above! :(

    We are currently work on different approches to fix it. What do you mean by.. "wrap then in using block"
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    Every AndroidJavaObject you create has a java global reference in it. If you create too many of them, you get such overflow error. If you simply stop referencing such object garbage collector will eventually destroy them, but you don't know when that will happen, so it's better to let them live longer that necessary. You can call Dispose() on the object once you no longer need it. If you only need the object temporarily, it's simpler to use using statement, so the compiler adds a call to Dispose() for you:
    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement
     
  6. Heero888

    Heero888

    Joined:
    Jun 18, 2017
    Posts:
    57
    I have the same issue.
    can you give an example on how to call Dispose() in C#?
    Thanks.