heremaps / here-android-sdk-examples

Java-based projects using the HERE SDK for Android.
Apache License 2.0
145 stars 191 forks source link

Proper way to re-init mapEngine after failed #281

Open bluesnow4425 opened 5 years ago

bluesnow4425 commented 5 years ago

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?

starand commented 5 years ago

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.

bluesnow4425 commented 5 years ago

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.

starand commented 5 years ago

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 commented 5 years ago

@bluesnow4425 is there any updates?

bluesnow4425 commented 5 years ago

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

starand commented 5 years ago

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

starand commented 5 years ago

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

bluesnow4425 commented 5 years ago

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.

starand commented 5 years ago

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.

bluesnow4425 commented 5 years ago

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.

starand commented 5 years ago

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.

bluesnow4425 commented 5 years ago

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.

Merlin1stHere commented 5 years ago

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

starand commented 4 years ago

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

bluesnow4425 commented 4 years ago

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.

starand commented 4 years ago

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

bluesnow4425 commented 4 years ago

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

victorgutsu commented 3 years ago

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