TextureView vs. GLSurfaceView - orientation change
Closed this issue · 2 comments
First of all I would like to say thanks to @yoavrofe for the last commit (#71). I am pretty sure using platformview is the correct way.
While testing I realized mapbox crashes after rotation change.
It can be prevented by using TextureView instead of GLSurfaceView:
MapboxMapOptions mbmo = new MapboxMapOptions();
mbmo.textureMode(true);
mapView = new MapView(context, mbmo);
Crash log:
D/EGL_emulation( 5197): eglCreateContext: 0xe0005360: maj 2 min 0 rcv 2 F/mapboxglexampl( 5197): java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: thread Thread[14,tid=5273,Native,Thread*=0xdfd46600,peer=0x1310a568,"GLThread 363"] using JNIEnv* from thread Thread[23,tid=5243,Runnable,Thread*=0xcb617800,peer=0x0," F/mapboxglexampl( 5197): java_vm_ext.cc:542] in call to DeleteGlobalRef F/mapboxglexampl( 5197): java_vm_ext.cc:542] from void com.mapbox.mapboxsdk.maps.renderer.MapRenderer.nativeOnSurfaceCreated() F/mapboxglexampl( 5197): java_vm_ext.cc:542] "GLThread 363" prio=5 tid=14 Runnable F/mapboxglexampl( 5197): java_vm_ext.cc:542] | group="main" sCount=0 dsCount=0 flags=0 obj=0x1310a568 self=0xdfd46600 F/mapboxglexampl( 5197): java_vm_ext.cc:542] | sysTid=5273 nice=0 cgrp=default sched=0/0 handle=0xc8e7f970 F/mapboxglexampl( 5197): java_vm_ext.cc:542] | state=R schedstat=( 6355962 778233 50 ) utm=0 stm=0 core=2 HZ=100 F/mapboxglexampl( 5197): java_vm_ext.cc:542] | stack=0xc8d7c000-0xc8d7e000 stackSize=1042KB F/mapboxglexampl( 5197): java_vm_ext.cc:542] | held mutexes= "mutator lock"(shared held) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #00 pc 004152f6 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+198) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #01 pc 0051048e /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+382) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #02 pc 0050b743 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+83) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #03 pc 0031a8b0 /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1088) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #04 pc 0031ad21 /system/lib/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, char*)+113) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #05 pc 000d60f7 /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+71) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #06 pc 000d46fc /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+364) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #07 pc 000d3bdb /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+811) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #08 pc 000d7876 /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::DeleteRef(char const*, _JNIEnv*, _jobject*, art::IndirectRefKind)+918) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #09 pc 000c034b /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::DeleteGlobalRef(_JNIEnv*, _jobject*)+43) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #10 pc 00024800 /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #11 pc 00025f9b /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #12 pc 00025fe3 /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #13 pc 00113407 /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #14 pc 0008a885 /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #15 pc 0008a8cf /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #16 pc 00086f82 /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #17 pc 00065829 /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/lib/x86/libmapbox-gl.so (???) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #18 pc 005f6b97 /system/lib/libart.so (art_quick_generic_jni_trampoline+71) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #19 pc 005f0b82 /system/lib/libart.so (art_quick_invoke_stub+338) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #20 pc 000a30ce /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+222) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #21 pc 0029bca2 /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+338) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #22 pc 00293e48 /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1048) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #23 pc 005bda66 /system/lib/libart.so (MterpInvokeDirect+342) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #24 pc 005e2e21 /system/lib/libart.so (ExecuteMterpImpl+14497) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #25 pc 00198dd0 /dev/ashmem/dalvik-classes.dex extracted in memory from /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/base.apk (deleted) (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onSurfaceCreated) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #26 pc 00266216 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #27 pc 0026c79c /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #28 pc 00293e2b /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #29 pc 005bcb1e /system/lib/libart.so (MterpInvokeSuper+1374) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #30 pc 005e2da1 /system/lib/libart.so (ExecuteMterpImpl+14369) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #31 pc 001999f8 /dev/ashmem/dalvik-classes.dex extracted in memory from /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/base.apk (deleted) (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onSurfaceCreated) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #32 pc 00266216 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #33 pc 0026c79c /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #34 pc 00293e2b /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #35 pc 005bcb1e /system/lib/libart.so (MterpInvokeSuper+1374) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #36 pc 005e2da1 /system/lib/libart.so (ExecuteMterpImpl+14369) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #37 pc 0018f2da /dev/ashmem/dalvik-classes.dex extracted in memory from /data/app/com.mapbox.mapboxglexample-ZWRbu4E5v47YrcHxFSnE2Q==/base.apk (deleted) (com.mapbox.mapboxsdk.maps.MapView$5.onSurfaceCreated+10) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #38 pc 00266216 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #39 pc 0026c79c /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #40 pc 00293e2b /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #41 pc 005bd574 /system/lib/libart.so (MterpInvokeInterface+1444) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #42 pc 005e2f21 /system/lib/libart.so (ExecuteMterpImpl+14753) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #43 pc 00ad5566 /system/framework/boot-framework.vdex (android.opengl.GLSurfaceView$GLThread.guardedRun+900) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #44 pc 00266216 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #45 pc 0026c79c /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+220) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #46 pc 00293e2b /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1019) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #47 pc 005bda66 /system/lib/libart.so (MterpInvokeDirect+342) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #48 pc 005e2e21 /system/lib/libart.so (ExecuteMterpImpl+14497) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #49 pc 00ad5b00 /system/framework/boot-framework.vdex (android.opengl.GLSurfaceView$GLThread.run+48) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #50 pc 00266216 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2093054539+598) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #51 pc 0026c68e /system/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+126) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #52 pc 005a953d /system/lib/libart.so (artQuickToInterpreterBridge+1277) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #53 pc 005f6c6d /system/lib/libart.so (art_quick_to_interpreter_bridge+77) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #54 pc 005f0b82 /system/lib/libart.so (art_quick_invoke_stub+338) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #55 pc 000a30ce /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+222) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #56 pc 004d3349 /system/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+89) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #57 pc 004d45f7 /system/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+471) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #58 pc 0050958c /system/lib/libart.so (art::Thread::CreateCallback(void*)+1484) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #59 pc 0008f005 /system/lib/libc.so (__pthread_start(void*)+53) F/mapboxglexampl( 5197): java_vm_ext.cc:542] native: #60 pc 000247fb /system/lib/libc.so (__start_thread+75) F/mapboxglexampl( 5197): java_vm_ext.cc:542] at com.mapbox.mapboxsdk.maps.renderer.MapRenderer.nativeOnSurfaceCreated(Native method) F/mapboxglexampl( 5197): java_vm_ext.cc:542] at com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onSurfaceCreated(MapRenderer.java:63) F/mapboxglexampl( 5197): java_vm_ext.cc:542] at com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onSurfaceCreated(GLSurfaceViewMapRenderer.java:48) F/mapboxglexampl( 5197): java_vm_ext.cc:542] at com.mapbox.mapboxsdk.maps.MapView$5.onSurfaceCreated(MapView.java:316) F/mapboxglexampl( 5197): java_vm_ext.cc:542] at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1539) F/mapboxglexampl( 5197): java_vm_ext.cc:542] at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270) F/mapboxglexampl( 5197): java_vm_ext.cc:542]
This is truly amazing, @moodstubos !
It solves the crash on hot reload and when the keyboard pops up as well!
will be continued in flutter-mapbox-gl/maps#1