customerio / customerio-reactnative

MIT License
23 stars 11 forks source link

Android crashes after 'java.io.FileNotFoundException' #106

Closed nnevalainen closed 1 year ago

nnevalainen commented 1 year ago

We have customers on Android 13 experiencing a fatal crash due to what seems like an internal error in the SDK.

SDK version: 2.0.1

Environment: Production

Are logs available? Not currently

Describe the bug Error in the dependency causes a fatal error crashing our application. We haven't identified the circumstances under which this happens. It concerns clients on Android 13 but doesn't happen every time.

File ---/io.customer/7ed642e4fb8cad095e58/queue/tasks/fe24ce7d-c198-41dc-9898-9a17633058b7.json: open failed: ENOENT (No such file or directory)

Exception java.io.FileNotFoundException:
  at libcore.io.IoBridge.open (IoBridge.java:574)
  at java.io.FileInputStream.<init> (FileInputStream.java:160)
  at kotlin.io.FilesKt__FileReadWriteKt.readText (FileReadWrite.kt:125)
  at kotlin.io.FilesKt__FileReadWriteKt.readText$default (FileReadWrite.kt:125)
  at io.customer.sdk.data.store.FileStorage.get (FileStorage.kt:62)
  at io.customer.sdk.queue.QueueStorageImpl.get (QueueStorage.kt:103)
  at io.customer.sdk.queue.QueueRunRequestImpl.runTasks (QueueRunRequest.kt:37)
  at io.customer.sdk.queue.QueueRunRequestImpl.goToNextTask (QueueRunRequest.kt:84)
  at io.customer.sdk.queue.QueueRunRequestImpl.runTasks (QueueRunRequest.kt:57)
  at io.customer.sdk.queue.QueueRunRequestImpl.access$runTasks (QueueRunRequest.kt:12)
  at io.customer.sdk.queue.QueueRunRequestImpl$runTasks$1.invokeSuspend
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at kotlinx.coroutines.internal.LimitedDispatcher.run (LimitedDispatcher.kt:42)
  at kotlinx.coroutines.scheduling.TaskImpl.run (Tasks.kt:95)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:570)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:749)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:677)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:664)
Caused by android.system.ErrnoException: open failed: ENOENT (No such file or directory)
  at libcore.io.Linux.open
  at libcore.io.ForwardingOs.open (ForwardingOs.java:563)
  at libcore.io.BlockGuardOs.open (BlockGuardOs.java:274)
  at libcore.io.ForwardingOs.open (ForwardingOs.java:563)
  at android.app.ActivityThread$AndroidOs.open (ActivityThread.java:8619)
  at libcore.io.IoBridge.open (IoBridge.java:560)

To Reproduce We haven't been able to reproduce the bug

Expected behavior

Additional context

Happens both foreground and background. Doesn't seem to affect IOS users.

Shahroz16 commented 1 year ago

Hey @nnevalainen, thank you for reporting this. We appreciate your feedback and will investigate further.

Zajozor commented 1 year ago

@Shahroz16 hey there, any progress on this? what information can we provide to make the resolution faster?

seems to be specific to Android x Samsung Galaxy (multiple versions) from our crash reports.

It is quite hard to prevent this in our code, and causes a straight crash of the whole app.

Shahroz16 commented 1 year ago

Hey @Zajozor and @nnevalainen the fix is out. Please make sure you clean the build and refresh the dependencies so that you have the latest version.

React native is using the Android native SDK underneath. Thank you for reporting and your patience.

Zajozor commented 1 year ago

ty @Shahroz16 appreciated!

the part with

NOTE: This method doesn't fix the root cause for files being not found. We're not yet able to reproduce this, but the code change helps preventing customer apps from crashing

does not sound very promising though tbh 😅

Shahroz16 commented 1 year ago

@Zajozor this is a very edge case, where file isn't found. That is yet to be figured out but it's in our pipeline rest assured 😊. But the fix make sure that app doesn't crash in any case.

And also, even if the file isn't found, events should be going out as expected.

Zajozor commented 1 year ago

All clear, thanks for the elaboration, much appreciated 🙏🏻