Skip to content
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

fix: run UI logic on the main thread [WPB-9458] #3055

Merged
merged 2 commits into from
May 29, 2024

Conversation

MohamadJaara
Copy link
Member

@MohamadJaara MohamadJaara commented May 29, 2024

BugWPB-9458 [Android] crash in wire activity


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

wire activity crashes when clearing view model

Solutions

we suspect that it have to do with changes in

override fun onResume() {
super.onResume()
lifecycleScope.launch(Dispatchers.Default) {
lockCodeTimeManager.get().observeAppLock()
// Listen to one flow in a lifecycle-aware manner using flowWithLifecycle
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
.first().let {
if (it) {
withContext(Dispatchers.Main) {
startActivity(
Intent(this@WireActivity, AppLockActivity::class.java)
)
}
}
}
}
proximitySensorManager.registerListener()
}
so reverting the changes should do the trick

Dependencies (Optional)

If there are some other pull requests related to this one (e.g. new releases of frameworks), specify them here.

Needs releases with:

  • GitHub link to other pull request

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Briefly describe how this change was tested and if applicable the exact steps taken to verify that it works as expected.

Notes (Optional)

Specify here any other facts that you think are important for this issue.

Attachments (Optional)

Attachments like images, videos, etc. (drag and drop in the text box)


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@MohamadJaara MohamadJaara requested review from a team, typfel and alexandreferris and removed request for a team May 29, 2024 13:01
@MohamadJaara MohamadJaara enabled auto-merge (squash) May 29, 2024 13:05
Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@ohassine ohassine left a comment

Choose a reason for hiding this comment

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

Why reverting all the commit and not just removing the default dispatcher from here ?

 lifecycleScope.launch(Dispatchers.Default) { 
         lockCodeTimeManager.get().observeAppLock() 
             // Listen to one flow in a lifecycle-aware manner using flowWithLifecycle 
             .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) 
             .first().let { 

Copy link
Contributor

Test Results

928 tests   928 ✅  12m 10s ⏱️
123 suites    0 💤
123 files      0 ❌

Results for commit a496deb.

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@MohamadJaara
Copy link
Member Author

Why reverting all the commit and not just removing the default dispatcher from here ?

 lifecycleScope.launch(Dispatchers.Default) { 
         lockCodeTimeManager.get().observeAppLock() 
             // Listen to one flow in a lifecycle-aware manner using flowWithLifecycle 
             .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) 
             .first().let { 

the changes does more or less nothing for example observePersistentConnectionStatus starts with viewModelScope.launch which which bring the function back to the main thread.

@MohamadJaara MohamadJaara requested a review from ohassine May 29, 2024 13:54
@ohassine
Copy link
Member

Why reverting all the commit and not just removing the default dispatcher from here ?

 lifecycleScope.launch(Dispatchers.Default) { 
         lockCodeTimeManager.get().observeAppLock() 
             // Listen to one flow in a lifecycle-aware manner using flowWithLifecycle 
             .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) 
             .first().let { 

the changes does more or less nothing for example observePersistentConnectionStatus starts with viewModelScope.launch which which bring the function back to the main thread.

No the child coroutine works on same dispatcher as the parent if we don't specify it on launch

@AndroidBob
Copy link
Collaborator

Build 5084 succeeded.

The build produced the following APK's:

@MohamadJaara MohamadJaara merged commit 2435b45 into release/candidate May 29, 2024
14 checks passed
@MohamadJaara MohamadJaara deleted the fix/WPB-9458- branch May 29, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants