NullPointerException: Attempt to invoke virtual method 'void com.esri.arcgisruntime.internal.jni.CoreDevice.b()' on a null object

3477
9
06-22-2021 01:10 AM
GeobuzonAplicaciones
New Contributor

I get this error on Crashlytics console, with no other information.

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.esri.arcgisruntime.internal.jni.CoreDevice.b()' on a null object reference
at com.esri.arcgisruntime.mapping.view.GeoView$RenderingThread.run(SourceFile:13)

I don't know where it is happening. I have no more information

I use kotlin and  com.esri.arcgisruntime:arcgis-android:100.11.0

this error happens some times not all time

0 Kudos
9 Replies
NicolasElgueta
New Contributor II

you should handle the null data inside the calls, you can add a try catch to handle the error.
if you can upload an extract of the code that produces the error.

0 Kudos
GeobuzonAplicaciones
New Contributor

This reply and nothing are the same. 

0 Kudos
RamaChintapalli
Esri Contributor

Hi,

We have seen this error reported from another source but with further debugging found that their app was incorrectly handling the orientation changes. In their case, the mapview was sent to a background activity/fragment and it is being disposed even before instantiating the mapview.

If you have any code that you can share, it can help us debug further you case. You can use one of our samples, try to repro your workflow and share with us.
https://github.com/Esri/arcgis-runtime-samples-android

Thanks
Rama

0 Kudos
GeobuzonAplicaciones
New Contributor

can you send the link to that case? (to see the code)

0 Kudos
JarvanMo
New Contributor

Hi @GeobuzonAplicaciones and @RamaChintapalli , I have a 100% case to reproduce this. I have a three tabs, ArcMap tab is at the end of these tabs and ArcMap is put together with other map. I have a switch button to turn on ArcMap visible or invisible. In this case, if I never switch it to ArcMap and ArcMap is never visible to users, then I call  

mapSwitcherRootBinding?.arcMapView?.dispose()

inside 

onDestroyView

 it must crash and this exception is JNI crash and can't be caught in Kotlin side. I think that one possible solution is can we judge if it is rendered or not before dispose ?

Dhruvin
New Contributor II

I can reproduce the CoreDevice.c() crash on 100.10.0 

CoreDevice.b() andCoreDevice.c() look like one is public and calls the other private function from the decompiled bytecode

I have noticed that I don't see the crash if I add a check to only dispose if current map has been loaded.

While this approach seems to work, can it cause any leaks during any specific circumstances if we don't call dispose ? @RamaChintapalli 

Calling dispose while in LOADING state seems to cause the crash.

val loadStatus = mapView.map.loadStatus
if (loadStatus == LoadStatus.LOADED) {
mapView.dispose()
}

I also noticed I don't see the crash if just changing the ESRI Android API version to 100.13.0 in the sample app.

It looks like this issue was fixed. Does anyone have the bug # to confirm ? @RamaChintapalli 

RamaChintapalli
Esri Contributor

HI Dhruvin,
Your approach to check the map status before disposing should work and not have any leaks. Again the idea is make sure dispose is not called before instantiating the map view.

 

I can confirm that we made a fix part of another internal issue in 100.13 to safeguard the above null pointer exception being thrown in case app tries to dispose map view without instantiating it. 

Thanks
Rama

Dhruvin
New Contributor II

Thanks for the update @RamaChintapalli. This helps alot.

Did you have a bug # for the internal issue?

0 Kudos
RamaChintapalli
Esri Contributor

Dhruvin,
It was done part of internal refactoring of the code. I don't have a public BUG# for it.

I have a public BUG#: BUG-000141674 for one of my above comments where the Fragment in the repro code is not handling the orientation changes appropriately and thereby causing same null pointer exception.

Thanks
Rama

0 Kudos