Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Accessing hidden field" error coming at run time in Android Kotlin code

I am building an Android App in Kotlin on Android Studio. I am connecting it to Firebase and Firestore.

Unfortunately, a code that used to work a while back, has started breaking now at run time with set of errors that look like should have been caught at compile time.

I am testing it on "Pixel XL API 29" emulator. I tried removing some blocks of codes etc. to figure out what could be happening, but the errors go away on removing some piece of code which I didn't even touch since quite some time:

db = FirebaseFirestore.getInstance()
val userData = hashMapOf(
    "user-id" to "theuserid",
    "language" to "hindi"
)

db.document("Data/Users/$userId").set(userData,SetOptions.merge())

(I had other event listeners etc. too here. I have omitted it for brevity. And also that I know it's an optional code. Having or not having the listeners is not making difference.)

So I am wondering what's going on here. While executing the app, the execution is not even reaching the part of code that I was recently updating.

Mentioned below are the errors. Any idea what could be going wrong?

W/DynamiteModule: Local module descriptor class for providerinstaller not found.
I/DynamiteModule: Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller: Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.hidl.base-V1.0-java.jar
    Returning zygote-cached class loader: /system/framework/android.hidl.manager-V1.0-java.jar
    Returning zygote-cached class loader: /system/framework/android.hidl.base-V1.0-java.jar
I/com.prash.pryst: The ClassLoaderContext is a special shared library.
I/chatty: uid=10133(com.prash.pryst) AsyncTask #1 identical 2 lines
I/com.prash.pryst: The ClassLoaderContext is a special shared library.
W/com.prash.pryst: Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ldalvik/system/DexPathList;->systemNativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryPathElements:[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
    Accessing hidden method Ldalvik/system/DexPathList;->makePathElements(Ljava/util/List;)[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
I/com.prash.pryst: Background young concurrent copying GC freed 30650(1701KB) AllocSpace objects, 0(0B) LOS objects, 19% free, 4294KB/5360KB, paused 1.123ms total 123.775ms
I/com.prash.pryst: Background concurrent copying GC freed 9816(280KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 6122KB/11MB, paused 5.428ms total 120.330ms
V/FA: Inactivity, disconnecting from the service
I/com.prash.pryst: Background young concurrent copying GC freed 81625(2972KB) AllocSpace objects, 1(188KB) LOS objects, 5% free, 11MB/11MB, paused 1.023ms total 204.780ms
W/com.prash.pryst: Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/security/x509/AlgorithmId;->get(Ljava/lang/String;)Lsun/security/x509/AlgorithmId; (greylist, reflection, allowed)
    Accessing hidden method Lsun/security/x509/AlgorithmId;->getName()Ljava/lang/String; (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)
I/com.prash.pryst: Background young concurrent copying GC freed 144924(6470KB) AllocSpace objects, 2(136KB) LOS objects, 23% free, 13MB/16MB, paused 526us total 240.717ms



Update: After reading the comments, I felt that the issue could be beyond the warnings that are shown. I looked at thread dump, and I see that quite a few threads are in "Waiting" state, and one of them is Firestore thread.

"FirestoreWorker@12477" daemon prio=5 tid=0x2ca nid=NA waiting
  java.lang.Thread.State: WAITING
      at sun.misc.Unsafe.park(Unsafe.java:-1)
      at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2109)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849)
      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@21.2.0:224)
      at java.lang.Thread.run(Thread.java:919)

What could be causing this?


Update 2: Managed to solve it

I was trying various stuff, and changed the way I was passing "Long" parameter to "update" function of firestore, and it seems to have worked. Not sure exactly what made it work. Me checking for it to be zero first, or different handling of !!

Old:

db = FirebaseFirestore.getInstance()
batch = db.batch()
batch.update(
 db.document("sunday"), "checked-items",
 FieldValue.increment(itemTable["sunday"]?.checkedItems?.toLong()!!)
)
batch.commit()

New:

db = FirebaseFirestore.getInstance()
batch = db.batch()
if ( itemTable["sunday"]!!.checkedItems > 0 ) {
 batch.update(
 db.document("sunday"), "checked-items",
 FieldValue.increment(itemTable["sunday"]!!.checkedItems.toLong())
 )
}
batch.commit()

Should I post this as answer?


Update 3 : And it is not working again.

Made some trivial changes like adding log events etc and it broke again. Even after undoing all the changes the error is not going. I am quite sure now that it is not connected to the changes I am making to the code. looked at thread dump, and this is what I have now:

"FirestoreWorker@12487" daemon prio=5 tid=0x3de nid=NA waiting
  java.lang.Thread.State: WAITING
      at sun.misc.Unsafe.park(Unsafe.java:-1)
      at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2109)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849)
      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@21.2.0:224)
      at java.lang.Thread.run(Thread.java:919)

Here's how the Thread dump screen looks like: https://photos.app.goo.gl/g5VEgK16RdJ7oCVj7

And this is how the warnings on the Run screen look like

W/com.prash.pryst: Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->systemNativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryPathElements:[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/DexPathList;->makePathElements(Ljava/util/List;)[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
W/com.prash.pryst: Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/security/x509/AlgorithmId;->get(Ljava/lang/String;)Lsun/security/x509/AlgorithmId; (greylist, reflection, allowed)
    Accessing hidden method Lsun/security/x509/AlgorithmId;->getName()Ljava/lang/String; (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)
V/FA: Inactivity, disconnecting from the service

Update 4: Solved finally

So, like how many of the other things turn out, this issue was also quite unrelated to the code changes I was making. Firestore calls were getting hung, because my daily quota of write operations had got over. Not sure why the calls were not failing, but were rather hung. I was not getting my Failure event listeners invoked.

like image 976
Mukesh Ghatiya Avatar asked Oct 21 '19 03:10

Mukesh Ghatiya


1 Answers

Checking the status of my daily quotas of 'write operations' in Firestore led to the breakthrough. My Firestore calls were getting hung due to quota getting over. Even the failure event listeners were not being invoked.

Now I changed to the plan of "pay as you go", and it seems to be working fine.

like image 180
Mukesh Ghatiya Avatar answered Oct 21 '22 18:10

Mukesh Ghatiya