2

I was using the mapbox sdk 6.3.0. I can add a polygon to the map and I am enabling the user to drag it by changing the feature and then updating the Featurecollection as follows:

features.set(features.indexOf(oldFeature), newFeature);
symbolsSource.setGeoJson(symbolsCollection);

Everything was working fine.

Then I tried to update the SDK from 6.3.0 to 7.3.0 Then all of a sudden while dragging I am getting the following crash(its intermittent but it is frequent)

2019-04-29 17:58:03.119 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: can't call java.lang.String com.mapbox.geojson.Feature.id() on null object 2019-04-29 17:58:03.119 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] in call to CallObjectMethodV 2019-04-29 17:58:03.119 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] "Thread-2368" prio=10 tid=65 Runnable 2019-04-29 17:58:03.119 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] | group="main" sCount=0 dsCount=0 flags=0 obj=0x1b740000 self=0x763d1b6800 2019-04-29 17:58:03.119 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] | sysTid=24204 nice=-10 cgrp=default sched=0/0 handle=0x76385da4f0 2019-04-29 17:58:03.120 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] | state=R schedstat=( 1253639661 195250540 1454 ) utm=117 stm=8 core=7 HZ=100 2019-04-29 17:58:03.120 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] | stack=0x76384df000-0x76384e1000 stackSize=1009KB 2019-04-29 17:58:03.120 24115-24204/com.app.fr.dev A/stresponder.de: java_vm_ext.cc:542] | held mutexes= "mutator lock"(shared held)....

There is no log which points to any point in my code. I am hoping this might be a problem with Mapbox SDK, because when I revert back to 6.3.0 its working fine. I am not able to pinpoint the actual issue. Can someone tell me how to actually debug such a crash?

Please let me know if I should provide more info.

Thanks in advance.

Edit: This is not a duplicate of nullpointer, because this is not happening to my code. It is happening inside the Mapbox sdk as you can see from the log. Also please note that the error thrown is JNI error.

hushed_voice
  • 3,161
  • 3
  • 34
  • 66
  • 3
    I agree this is not a duplicate of [NullPointer](https://stackoverflow.com/q/218384/6341943). There were several changes to the API between Mapbox Android Maps SDK 6.x and 7.x. You're probably seeing this NPE because there are some modifications to your code that still need to be made. I recommend checking out the migration guide: https://github.com/mapbox/mapbox-gl-native/wiki/Android-6.x-to-7.x-migration-guide – riastrad May 17 '19 at 14:33
  • @riastrad i have made the required changes in the migration guide. I raised an issue in the github repo. – hushed_voice May 18 '19 at 14:29
  • 1
    It's definitely not a duplicate. However 2 people voted that it's, few votes needed to reopen – Dmytro Rostopira Jun 13 '19 at 15:10
  • @DimaRostopira if you are facing the issue, mapbox provided a solution here https://github.com/mapbox/mapbox-gl-native/issues/14565#issuecomment-496923239 for the issue I raised. They also fixed it in the SDK which will be released in a couple of days. I hope some people with enough reputation vote to reopen this – hushed_voice Jun 14 '19 at 10:31
  • @free_style I'm not facing this issue, I'm not even using mapbox. Got here from reopen votes review queue =) I'm always careful with duplicate flags. Also, you should post this comment as an answer, knowing that there was an issue in lib itself is often useful – Dmytro Rostopira Jun 14 '19 at 11:02

1 Answers1

2

I raised an issue in Mapbox SDK and they have given me a way as a workaround for this issue.

While dragging, instead of setting the geojson directly like this

symbolsSource.setGeoJson(symbolsCollection);

We should set it like this:

symbolsSource.setGeoJson(FeatureCollection.fromFeatures(new ArrayList<>(symbolsCollection.features())));

They have also updated the SDK as well. Look here for the issue.

hushed_voice
  • 3,161
  • 3
  • 34
  • 66