getsentry / sentry-kotlin-multiplatform

Sentry SDK for Kotlin Multiplatform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem when used together with Phoenix library

mvarnagiris opened this issue · comments

Platform

Android

Installed

None

Version

0.5.0

Steps to Reproduce

  1. Use new init function that does not take Context and relies on ContentProvider
  2. In the app at some point do ProcessPhoenix.triggerRebirth(context)

Expected Result

App should not crash

Actual Result

App crashes with

Caused by: kotlin.UninitializedPropertyAccessException: lateinit property applicationContext has not been initialized
	at io.sentry.kotlin.multiplatform.SentryInit_androidKt.getApplicationContext(SentryInit.android.kt:17)
	at io.sentry.kotlin.multiplatform.SentryInit_androidKt.initSentry(SentryInit.android.kt:14)
	at io.sentry.kotlin.multiplatform.SentryBridge.init(SentryBridge.jvm.kt:21)
	at io.sentry.kotlin.multiplatform.Sentry.init(SentryKMP.kt:43)

I should mention the library com.jakewharton:process-phoenix:2.1.2

Hi thanks for raising this, we'll take a look!

What's your production use case for this? As far as I can see triggerRebirth restarts the application so it might impede with the way content providers are loaded?

There are cases in our app where we need to restart. Also this issue happens when we are expecting results from other activities that are started in separate process. There must be a way to make this work. because Firebase libraries do similar thing with ContentProvider and they work fine.

Got it, sorry for the issue.

@romtsn do you have more insight here?

No worries. You should be able to reproduce the issue fairly easily, but if you need help with that let me know

@mvarnagiris the fix is fairly straightforward, just removed the lateinit and replaced it with a nullable. after some testing the app restart is triggered twice and only on the second iteration the content providers are triggered. I opened a PR for the fix

This is now released with 0.6.0 please check if that fixes the issue for you

Yes I can confirm that the fix helped. Thanks a lot for prompt response and the fix 🙇