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 bitmap widgets not rendering or crashing on specific devices #1834

Merged
merged 6 commits into from
Nov 16, 2022

Conversation

kiryldz
Copy link
Contributor

@kiryldz kiryldz commented Nov 14, 2022

Summary of changes

Some devices (using Adreno GPUs) could not render bitmap widgets as depth test is enabled and thus widgets are rendered under the map.

The inital fix was to explicitly disable depth test on render thread OpenGL context before drawing the widget - however that just partly fixes the issue.

However correct fix also fixing atmosphere crash on Adreno GPUs is to use shared context when creating MapSurface / MapView with widgets. Both MapSurface / MapView will throw runtime exception now if widgets are trying to be added and MapOptions.contextMode != SHARED.

At the same time for the Mapbox Android Auto extension MapOptions.contextMode = SHARED is enforced in any case as Android Auto introduces compass / bitmap widgets which are most likely used by the user and preventing runtime crashing.

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.

@kiryldz kiryldz added the bug 🪲 Something isn't working label Nov 14, 2022
@kiryldz kiryldz requested a review from a team as a code owner November 14, 2022 15:17
@kiryldz kiryldz self-assigned this Nov 14, 2022
@kiryldz kiryldz changed the title Fix bitmap widgets not rendering on specific devices Fix bitmap widgets not rendering or crashing on specific devices Nov 15, 2022
@paulrenn67 paulrenn67 self-requested a review November 15, 2022 11:56
sdk/src/main/java/com/mapbox/maps/MapSurface.kt Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@kiryldz kiryldz force-pushed the kdz-fix-xiaomi-widget-render branch 2 times, most recently from 5f8eb19 to ad2f86a Compare November 15, 2022 15:18
every { lifecycle } returns lifecycleOwner.lifecycle
}

mockkStatic("com.mapbox.maps.MapboxLogger")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mockkStatic("com.mapbox.maps.MapboxLogger")
mockkStatic(MapboxLoggerClassName)

verify(exactly = 1) {
mapboxCarMap.setup(sessionCarContext, capture(mapInitOptions))
}
assert(mapInitOptions.captured.mapOptions.contextMode == ContextMode.SHARED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert(mapInitOptions.captured.mapOptions.contextMode == ContextMode.SHARED)
assertEquals(mapInitOptions.captured.mapOptions.contextMode, ContextMode.SHARED)

Copy link
Member

@pengdev pengdev left a comment

Choose a reason for hiding this comment

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

LGTM with a nit

@kiryldz kiryldz merged commit f05f54d into main Nov 16, 2022
@kiryldz kiryldz deleted the kdz-fix-xiaomi-widget-render branch November 16, 2022 14:56
kiryldz added a commit that referenced this pull request Nov 16, 2022
* MAPSAND-613 disable depth test for widgets

* changelog

* Use better approach

* Add tests

* Always throw exception in SDK, update AA extension

* Remove warning when no context specified
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.

7 participants