Skip to content

LIBMOBILE-1277- fix androidx lifecycle causes analytics init in background crash #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2023

Conversation

RawatRaveena
Copy link
Contributor

LIBMOBILE-1277

  • fix androidx lifecycle causes analytics init in background crash

- fix androidx lifecycle causes analytics init in background crash
@RawatRaveena RawatRaveena requested a review from wenxi-zeng April 28, 2023 05:34
@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2023

Codecov Report

Patch coverage has no change and project coverage change: +33.69 🎉

Comparison is base (3d49b95) 45.57% compared to head (a29033e) 79.26%.

Additional details and impacted files
@@              Coverage Diff              @@
##               main     #158       +/-   ##
=============================================
+ Coverage     45.57%   79.26%   +33.69%     
- Complexity       14      474      +460     
=============================================
  Files             8       74       +66     
  Lines           858     5965     +5107     
  Branches         85      719      +634     
=============================================
+ Hits            391     4728     +4337     
- Misses          437      670      +233     
- Partials         30      567      +537     

see 66 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

run(Runnable { lifecycle.removeObserver(this) })
}
}
private fun run(runnable: Runnable) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to use runnable in kotlin, try high order function and lambda

if (Looper.myLooper() == Looper.getMainLooper()) {
runnable.run()
} else {
HANDLER.post(runnable)
Copy link
Contributor

@wenxi-zeng wenxi-zeng Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in kotlin, the correct way to post to main thread is

scope.launch(Dispatchers.Main) {
  // do something on main thread
}

@wenxi-zeng wenxi-zeng requested review from didiergarcia and wenxi-zeng and removed request for wenxi-zeng May 2, 2023 19:43
@wenxi-zeng wenxi-zeng merged commit 1f8250e into main May 9, 2023
@wenxi-zeng wenxi-zeng deleted the LIBMOBILE-1277 branch May 9, 2023 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants