diff --git a/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/jni/JNIDeallocator.kt b/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/jni/JNIDeallocator.kt --- a/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/jni/JNIDeallocator.kt +++ b/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/jni/JNIDeallocator.kt @@ -34,7 +34,10 @@ class JNIDeallocator(shouldCreateDestructorThread: Boolean = true) : AutoCloseab // Referent of PhantomReference were garbage collected so we can remove it from our registry. // Note that we don't have to call `deallocate` method - it was called [com.facebook.jni.HybridData]. val current = referenceQueue.remove() - synchronized(this) { + // Goon: `this` w `object : Thread` to watek, nie deallocator. Blokada na watku + // nic nie chronila i remove szedl rownolegle z iteracja w deallocate(), stad + // ConcurrentModificationException przy przeladowaniu JS (Sentry GOON-48). + synchronized(this@JNIDeallocator) { destructorMap.remove(current) } } catch (e: InterruptedException) { @@ -65,10 +68,13 @@ class JNIDeallocator(shouldCreateDestructorThread: Boolean = true) : AutoCloseab * Deallocates valid references and clears the internal registry. */ internal fun deallocate() = synchronized(this) { - destructorMap.values.forEach { + // Goon: kopia przed wolaniem deallocate(), ktore moze wrocic do tej mapy z tego + // samego watku (blokada jest reentrant, wiec by nie zatrzymala), GOON-48. + val refs = destructorMap.values.toList() + destructorMap.clear() + refs.forEach { it.get()?.deallocate() } - destructorMap.clear() destructorThread?.interrupt() }