here-android-sdk-examples icon indicating copy to clipboard operation
here-android-sdk-examples copied to clipboard

Proper way to re-init mapEngine after failed

Open bluesnow4425 opened this issue 5 years ago • 18 comments

hi we found out that in certain brands devices, map engine gets failed to initialize easily after kill the app process and re-launch. I tried to re-init the mapEngine when i got init Error, but it seems that the map engine gets failed forever if it gets it once. (in my case the error states can't init twice) Is there any better way to re-init map engine while it inits fail?

bluesnow4425 avatar Sep 05 '19 06:09 bluesnow4425

Hi @bluesnow4425 Can you share device names? Which error do you get? We never bumped in that issue. What yo can try, to delete SDK cache (try to remove /sdcard/.here-maps folder). Also you can try to use MapSettings.setIsolatedDiskCacheRootPath() which allows to change SDK cache path.

starand avatar Sep 05 '19 06:09 starand

Mostly if we use google phone, it happens more frequently. If we force to kill the app process, there's about 10-20% to crash. I use MapSettings.setIsolatedDiskCacheRootPath() in Application class which executes as soon as app launches.

bluesnow4425 avatar Sep 06 '19 03:09 bluesnow4425

What was the error code? Or can you share the crash log? We tried to reproduce on Google Pixel devices, but we could not.

starand avatar Sep 06 '19 06:09 starand

@bluesnow4425 is there any updates?

starand avatar Sep 16 '19 12:09 starand

i remembered it's an unknown error. I'll post the log in a day or two.

bluesnow4425 avatar Sep 17 '19 08:09 bluesnow4425

@bluesnow4425 please add more details like error.getDetails() and error.getStackTrace(). Thank you!

starand avatar Sep 17 '19 08:09 starand

Most likely you are trying to init MapEngine/MapFragment in different threads. Try to synchronize this.

starand avatar Sep 18 '19 09:09 starand

Unknown error occurred during engine init i think this is details. and I'm getting

java.lang.RuntimeException: Cannot initialize the engine twice
        at com.nokia.maps.MapsEngine.<init>(MapsEngine.java:21)
        at com.nokia.maps.MapsEngine.c(MapsEngine.java:9)
        at com.nokia.maps.MapsEngine.a(MapsEngine.java:36)
        at com.nokia.maps.MapsEngine.a(MapsEngine.java:24)
        at com.here.android.mpa.common.MapEngine.init(MapEngine.java:1)

as stacktrace.

It says that the engine can't initialize twice, but first time fails and MapEngine.isInitialized() returns false either. Tried several ways but the only one works is to exit the app process and relaunchs again.

bluesnow4425 avatar Sep 18 '19 09:09 bluesnow4425

Ok, we never observed this issue, but from sources, it looks like initialization is done in at least two parallel threads. Other customers also do not report the issue. So it is difficult to reproduce. Can you remove business logic from your app and share with us? Or can you add minimal changes to the github sample in order to reproduce? Please share devices models as well.

starand avatar Sep 18 '19 10:09 starand

https://github.com/bluesnow4425/here_map_init_research here's the repo. Tried and crash reproduce-able. I'm using google pixel 2 with latest android version.

bluesnow4425 avatar Sep 20 '19 06:09 bluesnow4425

Ok, I did not manage to get to the end of registration process =), but I saw few mapEngine/Fragment init() calls. That cause synchronization issue. As we are near the end of SDK 3.13 release, the fix can be included only in 3.14 release. As a workaround, synchronize all calls of MapEngine (Fragment calls MapEngine init method internally). For your case you can init Map on the application start (once), and the next calls (even simultaneous) should run w/o problems. Or add some pause before calling init() method second time.

starand avatar Sep 20 '19 09:09 starand

thanks for feedback. Originally we call init only on the application start, but init failed issue happened, so we tried to init again and add another init to somewhere else. I'll try the process you suggested.

bluesnow4425 avatar Sep 26 '19 06:09 bluesnow4425

@bluesnow4425 What is the first error you got before running mapEngine init again? Please provide error code and details string (Error.getDetails).

Merlin1stHere avatar Sep 30 '19 07:09 Merlin1stHere

@bluesnow4425 is there any updates? Could you please provide requested info? Or did you solve the issue?

starand avatar Oct 24 '19 07:10 starand

We still facing init error sometimes, especially after the app crashes. We do Runtime.getRuntime().exit(0) to kill the whole process and relaunch the app again.

bluesnow4425 avatar Oct 29 '19 03:10 bluesnow4425

But was you able to get the init error? "What is the first error you got before running mapEngine init again?"

starand avatar Oct 29 '19 07:10 starand

I think it's the same with my post above.

bluesnow4425 avatar Oct 31 '19 04:10 bluesnow4425

Does somebody resolved that issue? im still able to reproduce same error as above https://github.com/heremaps/here-android-sdk-examples/issues/384

victorgutsu avatar Jan 26 '21 07:01 victorgutsu