gluonhq / attach

GNU General Public License v3.0
50 stars 26 forks source link

[Android] Black screen with PositionService #296

Closed jperedadnr closed 2 years ago

jperedadnr commented 2 years ago

Deploying to Android the HelloMaps sample with

<javafx.version>17.0.1</javafx.version>
        <charm.version>6.1.0</charm.version>
        <charm.cloudlink.version>6.0.7</charm.cloudlink.version>
        <glisten.afterburner.version>2.1.0</glisten.afterburner.version>
        <attach.version>4.0.13</attach.version>
        <connect.version>2.0.1</connect.version>
        <javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
        <gluonfx.maven.plugin.version>1.0.12</gluonfx.maven.plugin.version>

there is a black screen. If the load of the PositionService is delayed, the MapView loads fine. When the service is instantiated, touch doesn't respond and the app crashes with:

03-19 20:53:00.565 28294 28294 E GraalGluon: Native Dalvik layer got touch event, pass to native Graal layer...
03-19 20:53:00.565 28294 28294 I GLASS   : Call InternalSurfaceView_onMultiTouchEventNative
03-19 20:53:00.565 28294 28321 D GraalCompiled: don't add points, primary = -1
03-19 20:53:00.565 28294 28294 E GraalGluon: Native Dalvik layer got touch event, passed to native Graal layer...
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630] Runtime aborting...
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630] Dumping all threads without mutator lock held
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630] All threads:
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630] DALVIK THREADS (18):
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630] "Thread-3" prio=5 tid=20 Runnable
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | group="" sCount=0 dsCount=0 flags=0 obj=0x13901db8 self=0x6f198e2800
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | sysTid=28326 nice=0 cgrp=default sched=0/0 handle=0x6f0defbd50
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | state=R schedstat=( 411770616 86251934 1146 ) utm=23 stm=17 core=3 HZ=100
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | stack=0x6f0de05000-0x6f0de07000 stackSize=991KB
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | held mutexes= "abort lock" "mutator lock"(shared held)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #00 pc 0000000000412794  /apex/com.android.runtime/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #01 pc 00000000004f9c5c  /apex/com.android.runtime/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+508)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #02 pc 000000000051429c  /apex/com.android.runtime/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+812)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #03 pc 000000000050d2f0  /apex/com.android.runtime/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+456)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #04 pc 000000000050c6fc  /apex/com.android.runtime/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+1792)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #05 pc 00000000004b9d8c  /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+1352)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #06 pc 000000000000c634  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+604)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #07 pc 00000000003781f0  /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1608)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #08 pc 00000000003784a0  /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+180)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #09 pc 00000000004ffc84  /apex/com.android.runtime/lib64/libart.so (art::Thread::DecodeJObject(_jobject*) const+780)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #10 pc 0000000000369c80  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckInstance(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck::InstanceKind, _jobject*, bool)+96)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #11 pc 0000000000368fec  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+592)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #12 pc 00000000003685d8  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+624)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #13 pc 000000000036bde4  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::CheckJNI::GetMethodIDInternal(char const*, _JNIEnv*, _jclass*, char const*, char const*, bool)+668)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   native: #14 pc 00000000013fba30  /data/app/com.gluonhq.samples.hellomaps-ZWTNigTdieUfsPmi8ApicA==/lib/arm64/libsubstrate.so (initializeDalvikHandles+316)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   (no managed stack frames)
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630] "main" prio=5 tid=1 Native
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | group="" sCount=1 dsCount=0 flags=1 obj=0x71f6dd98 self=0x7003758000
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | sysTid=28294 nice=-10 cgrp=default sched=0/0 handle=0x7004caaed0
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | state=S schedstat=( 526684070 67658120 617 ) utm=38 stm=13 core=3 HZ=100
03-19 20:53:00.688 28294 28326 F mples.hellomap: runtime.cc:630]   | stack=0x7ff2b3e000-0x7ff2b40000 stackSize=8192KB
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   | held mutexes=
        03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   kernel: (couldn't read /proc/self/task/28294/stack)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   native: #00 pc 00000000000ced58  /apex/com.android.runtime/lib64/bionic/libc.so (__epoll_pwait+8)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   native: #01 pc 0000000000017c30  /system/lib64/libutils.so (android::Looper::pollInner(int)+148)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   native: #02 pc 0000000000017afc  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+56)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   native: #03 pc 0000000000136da4  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at android.os.MessageQueue.nativePollOnce(Native method)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at android.os.MessageQueue.next(MessageQueue.java:336)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at android.os.Looper.loop(Looper.java:174)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at android.app.ActivityThread.main(ActivityThread.java:7356)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at java.lang.reflect.Method.invoke(Native method)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
03-19 20:53:00.689 28294 28326 F mples.hellomap: runtime.cc:630]
...
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630] Aborting thread:
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630] "Thread-3" prio=5 tid=20 Native
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   | group="" sCount=0 dsCount=0 flags=0 obj=0x13901db8 self=0x6f198e2800
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   | sysTid=28326 nice=0 cgrp=default sched=0/0 handle=0x6f0defbd50
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   | state=R schedstat=( 487338370 87557767 1238 ) utm=28 stm=19 core=3 HZ=100
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   | stack=0x6f0de05000-0x6f0de07000 stackSize=991KB
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   | held mutexes= "abort lock"
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   native: #00 pc 0000000000412794  /apex/com.android.runtime/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140)
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   native: #01 pc 00000000004f9c5c  /apex/com.android.runtime/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+508)
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   native: #02 pc 00000000004cb474  /apex/com.android.runtime/lib64/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, art::Thread*) const+60)
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   native: #03 pc 00000000004b9e00  /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+1468)
03-19 20:53:00.691 28294 28326 F mples.hellomap: runtime.cc:630]   native: #04 pc 000000000000c634  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+604)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #05 pc 00000000003781f0  /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1608)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #06 pc 00000000003784a0  /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+180)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #07 pc 00000000004ffc84  /apex/com.android.runtime/lib64/libart.so (art::Thread::DecodeJObject(_jobject*) const+780)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #08 pc 0000000000369c80  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckInstance(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck::InstanceKind, _jobject*, bool)+96)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #09 pc 0000000000368fec  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+592)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #10 pc 00000000003685d8  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+624)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #11 pc 000000000036bde4  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::CheckJNI::GetMethodIDInternal(char const*, _JNIEnv*, _jclass*, char const*, char const*, bool)+668)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   native: #12 pc 00000000013fba30  /data/app/com.gluonhq.samples.hellomaps-ZWTNigTdieUfsPmi8ApicA==/lib/arm64/libsubstrate.so (initializeDalvikHandles+316)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]   (no managed stack frames)
03-19 20:53:00.692 28294 28326 F mples.hellomap: runtime.cc:630]
--------- beginning of crash
03-19 20:53:00.692 28294 28326 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 28326 (Thread-3), pid 28294 (mples.hellomaps)
03-19 20:53:00.780 28476 28476 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
03-19 20:53:00.790   820   820 I /system/bin/tombstoned: received crash request for pid 28326
03-19 20:53:00.792 28476 28476 I crash_dump64: performing dump of process 28294 (target tid = 28326)
03-19 20:53:00.802 28476 28476 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-19 20:53:00.802 28476 28476 F DEBUG   : Build fingerprint: 'google/marlin/marlin:10/QP1A.191005.007.A3/5972272:user/release-keys'
03-19 20:53:00.802 28476 28476 F DEBUG   : Revision: '0'
03-19 20:53:00.802 28476 28476 F DEBUG   : ABI: 'arm64'
03-19 20:53:00.803 28476 28476 F DEBUG   : Timestamp: 2022-03-19 20:53:00+0100
03-19 20:53:00.803 28476 28476 F DEBUG   : pid: 28294, tid: 28326, name: Thread-3  >>> com.gluonhq.samples.hellomaps <<<
        03-19 20:53:00.803 28476 28476 F DEBUG   : uid: 10183
03-19 20:53:00.803 28476 28476 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
        03-19 20:53:00.803 28476 28476 F DEBUG   : Abort message: 'JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x6f1745e650'
03-19 20:53:00.803 28476 28476 F DEBUG   :     x0  0000000000000000  x1  0000000000006ea6  x2  0000000000000006  x3  0000006f0defa5a0
03-19 20:53:00.803 28476 28476 F DEBUG   :     x4  6500000000000000  x5  6500000000000000  x6  6500000000000000  x7  0000000000008065
03-19 20:53:00.803 28476 28476 F DEBUG   :     x8  00000000000000f0  x9  8b5a980ad3507532  x10 fffffff0fffffbdf  x11 0000000000000000
03-19 20:53:00.803 28476 28476 F DEBUG   :     x12 0000000000000030  x13 0000000000000002  x14 0000000000000008  x15 0000000000000000
03-19 20:53:00.803 28476 28476 F DEBUG   :     x16 00000070015718b8  x17 000000700154f710  x18 0000006f08ed7618  x19 00000000000000ac
03-19 20:53:00.803 28476 28476 F DEBUG   :     x20 0000000000006e86  x21 00000000000000b2  x22 0000000000006ea6  x23 00000000ffffffff
03-19 20:53:00.804 28476 28476 F DEBUG   :     x24 0000006f0defc020  x25 00000000ffffffff  x26 0000000000000012  x27 0000000000000005
03-19 20:53:00.804 28476 28476 F DEBUG   :     x28 0000006f7e4b3012  x29 0000006f0defa650
03-19 20:53:00.804 28476 28476 F DEBUG   :     sp  0000006f0defa580  lr  000000700150244c  pc  000000700150246c
03-19 20:53:00.811 28476 28476 F DEBUG   :
03-19 20:53:00.811 28476 28476 F DEBUG   : backtrace:
03-19 20:53:00.811 28476 28476 F DEBUG   :       #00 pc 000000000008246c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 5812256023147338b8a9538321d4c456)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #01 pc 00000000004ba0c4  /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+2176) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #02 pc 000000000000c634  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+604) (BuildId: 83d94b0adf649fc558a5414c3ce539d7)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #03 pc 00000000003781f0  /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1608) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #04 pc 00000000003784a0  /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+180) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #05 pc 00000000004ffc84  /apex/com.android.runtime/lib64/libart.so (art::Thread::DecodeJObject(_jobject*) const+780) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #06 pc 0000000000369c80  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckInstance(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck::InstanceKind, _jobject*, bool)+96) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #07 pc 0000000000368fec  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+592) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #08 pc 00000000003685d8  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+624) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #09 pc 000000000036bde4  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::CheckJNI::GetMethodIDInternal(char const*, _JNIEnv*, _jclass*, char const*, char const*, bool)+668) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
03-19 20:53:00.811 28476 28476 F DEBUG   :       #10 pc 00000000013fba30  /data/app/com.gluonhq.samples.hellomaps-ZWTNigTdieUfsPmi8ApicA==/lib/arm64/libsubstrate.so (initializeDalvikHandles+316)
03-19 20:53:00.813 28294 28294 V GraalActivity: Activity, get touch event, pcount = 1

Note the crash happens with this

Abort message: 'JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x6f1745e650'

in initializeDalvikHandles() when retrieving the dalvikPositionService class

https://github.com/gluonhq/attach/blob/master/modules/position/src/main/native/android/c/position.c#L48.

The issue started with this commit.

After the refactoring there is a global static jclass jPositionServiceClass, so when calling initializeDalvikHandles there shouldn't be a local jclass jPositionServiceClass anymore.

Removing jclass fixes the issue.

Issue reported initially here: https://stackoverflow.com/questions/71490922/gluonmobile-application-hangs-when-reading-position-from-positionservice and here: https://stackoverflow.com/questions/71477853/gluonmobile-application-gives-a-black-screen-with-positionservice