I have an odd crash in release mode only. Following code crashes with bad access 0x0 when accessing the
by lazy
part:
Copy code
val preferences by lazy { SharedBaseInjector.get().preferences } // Crash in this line
fun something() {
SharedBaseInjector.get().preferences // This is fine
val x = preferences.someValue
....
}
In debug mode everything is fine. If I wrap the preferences variable in an object it’s also fine in release mode:
Copy code
private object Cache {
val preferences by lazy { SharedBaseInjector.get().preferences }
}
fun something() {
val x = Cache.preferences.someValue
....
}
Anyone having a clue what’s going on? The object fixes it for me…but I’d still like to understand what’s going on
h
Hee Fan
12/11/2022, 11:58 PM
Crash on iOS when get into shared module?
c
Christian Würthenr
12/12/2022, 8:21 AM
On iOS when it calls
by lazy
Christian Würthenr
12/12/2022, 8:21 AM
Android is working fine
h
Hee Fan
12/14/2022, 2:30 AM
@Christian Würthenr, I have encountered the similar issue before, android works fine but iOS keep crashing. It’s caused by different initialisation timing between kotlin and swift when you use