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

MAPSAND-366 Fix ANR while open and close MapView quickly with textureView set to true, fix potential crash on RenderHandlerThread creation. #1567

Merged
merged 11 commits into from
Aug 10, 2022

Conversation

paulrenn67
Copy link
Contributor

@paulrenn67 paulrenn67 commented Aug 8, 2022

Summary of changes

Lazy initialization of handlerThread is not really needed since anyone who creates an instance of RenderHandlerThread is going to render a map, and can cause issues with handler/handlerThread values not being aligned.

Also fixed and renamed started method to avoid potential deadlock due to race condition on some devices when onSurfaceDestroyed is called right after destroy.

Added new tests to check start/stop works as expected.

User impact (optional)

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Optimize code for java consumption (@JvmOverloads, @file:JvmName, etc).
  • Add example if relevant.
  • Document any changes to public APIs.
  • Run make update-api to update generated api files, if there's public API changes, otherwise the verify-api-* CI steps might fail.
  • Update CHANGELOG.md or use the label 'skip changelog', otherwise check changelog CI step will fail.
  • If this PR is a v10.[version] release branch fix / enhancement, merge it to main firstly and then port to v10.[version] release branch.

Fixes: < Link to related issues that will be fixed by this pull request, if they exist >

PRs must be submitted under the terms of our Contributor License Agreement CLA.

@paulrenn67 paulrenn67 requested a review from a team as a code owner August 8, 2022 13:38
@CLAassistant
Copy link

CLAassistant commented Aug 8, 2022

CLA assistant check
All committers have signed the CLA.

@yunikkk
Copy link
Contributor

yunikkk commented Aug 8, 2022

Not sure I see how the fix prevents the ANR, could you elaborate? isAlive will just return false if start was not called, right?
However I agree we might not need a separate start since it's used in single place and constructor call is coupled with start

@paulrenn67
Copy link
Contributor Author

Not sure I see how the fix prevents the ANR, could you elaborate? isAlive will just return false if start was not called, right? However I agree we might not need a separate start since it's used in single place and constructor call is coupled with start

Hi, originally handlerThread was lateinit, so calling the started method would result in a call on an uninitialized object. This fix essentially just ensures that handlerThread is always valid.

@yunikkk
Copy link
Contributor

yunikkk commented Aug 9, 2022

``

Hi, originally handlerThread was lateinit, so calling the started method would result in a call on an uninitialized object. This fix essentially just ensures that handlerThread is always valid.

Ok, so it would then crash, and this PR is about preventing this crash and not ANR, got it.

@paulrenn67
Copy link
Contributor Author

``

Hi, originally handlerThread was lateinit, so calling the started method would result in a call on an uninitialized object. This fix essentially just ensures that handlerThread is always valid.

Ok, so it would then crash, and this PR is about preventing this crash and not ANR, got it.

Yes, this should fix another crash that I noticed just with code inspection. I think Kevin's fix is also combined here.

Copy link
Contributor

@kiryldz kiryldz left a comment

Choose a reason for hiding this comment

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

@paulrenn67 🎉 on your first PR here!
Several notes:

  • please add changelog entry, smth like Fix possible ANR when destroying renderer
  • please sign an SLA otherwise PR could not be merged
  • rename the PR and update PR description as the scope slightly changed with your fixes

@kiryldz kiryldz added the bug 🪲 Something isn't working label Aug 10, 2022
@yunikkk
Copy link
Contributor

yunikkk commented Aug 10, 2022

Looks good!

@paulrenn67 paulrenn67 changed the title MAPSAND-366 remove lazy initialization of HandlerThread MAPSAND-366 Fix ANR while open and close MapView quickly with textureView set to true, fix potential crash on RenderHandlerThread creation. Aug 10, 2022
@paulrenn67 paulrenn67 force-pushed the MAPSAND-366-render-handler-thread branch from 86f43c2 to 218670c Compare August 10, 2022 11:41
@paulrenn67
Copy link
Contributor Author

@paulrenn67 🎉 on your first PR here! Several notes:

  • please add changelog entry, smth like Fix possible ANR when destroying renderer
  • please sign an SLA otherwise PR could not be merged
  • rename the PR and update PR description as the scope slightly changed with your fixes

@kiryldz hopefully all ok now?

CHANGELOG.md Outdated Show resolved Hide resolved
@paulrenn67 paulrenn67 force-pushed the MAPSAND-366-render-handler-thread branch from 95f4b80 to b7fb192 Compare August 10, 2022 13:10
@paulrenn67 paulrenn67 merged commit 7ad2031 into main Aug 10, 2022
@paulrenn67 paulrenn67 deleted the MAPSAND-366-render-handler-thread branch August 10, 2022 14:08
mapbox-github-ci-writer-public-1 bot pushed a commit that referenced this pull request Mar 28, 2023
…1567)

* Change approach to understand if device is connected to WiFi (#1565)

* Change approach to understand if device is on WiFi

* Rm comment

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants