Version 1.10.4
introduced a runtime warning when setup(amplitude:)
is called
#246
Labels
bug
Something isn't working
Expected Behavior
Constructing the
Amplitude
object exhibits no runtime warnings when called on a background thread. Application developers should not be forced to initialize third party SDKs on the main thread as that reduces our ability to optimize our launch experience for our users.Current Behavior
Prior to version
1.10.4
, constructing theAmplitude
object on a background thread was warning free.However, starting in
1.10.4
there is now a runtime warning emitted by Xcode's "main thread checker" onIOSLifecycleMonitor.setup(amplitude:)
whenAmplitude
is constructed on a background thread. This is becausesetup(amplitude:)
is now accessing theapplicationState
property from aUIApplication
instance.Possible Solution
In order to detach the ability to know what the current application state is at any time regardless of what thread is checking, there needs to be a high-level monitor that listens for application state changes (which would occur on the main thread) and update a primitive property in that monitor. Anything that needs to know the application state uses the monitor's value instead of reading
applicationState
from aUIApplication
instance.Until this bug is fixed, we have to do one of the following:
Amplitude
object is created on the main thread, or1.10.4
.Steps to Reproduce
This is a universal example -- not my actual implementation.
This results in this emission from the main thread checker at runtime:
Environment
1.10.4
iOS
-- the specific version is irrelevantThe text was updated successfully, but these errors were encountered: