Bug 1779638 - Kotlin: Add a hook to run tasks after init #2116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We saw some intermittents on Android Components failing in the
assert(isInitialized())
line.This leads me to believe that it runs before Glean.initialize is
finished off-thread.
To fix this we introduce a new task queue: run things right after
Glean.initialize calls back into the wrapper.
We need to be careful though: This is triggered from the Rust side so we
can't call back and forth between Kotlin and Rust inside that task or we
risk deadlocks.
But in this instance we're safe:
In theory there's a race condition still there, because we use
unsynchronized access to the
afterInitQueue
, but really ... it's testmode and might just be fine enough for all we care? Let's hope so.
I am not able to reproduce the same error as in the intermittent locally
at all (neither in the simulator nor on an actual device), so really I
don't know if this "fixes" it.
The only way to test this out is to go through a release, get it into
A-C and then re-enable the tests and hope for the best.