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 crash when user updates icons with images of different sizes #2989

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alasram
Copy link
Collaborator

@alasram alasram commented Nov 5, 2024

We run into several crashes related to users calling MapLibreMap.getStyle.addImage(imageId, imageBitmap) with the same imageId but imageBitmap with different sizes. In response to this call, MapLibre finds the texture atlas rectangle corresponding to imageId and updates the rectangle with imageBitmap without checking if imageBitmap fits the rectangle. This PR is a quick workaround to avoid the crash and unblock users. If imageBitmap is lager than the atlas rectangle for imageId then imageBitmap gets resized to fit the rectangle.
A probably better approach is to detect these cases and repack the atlas such as the rectangle allocated to imageId is the maximum size for all previously updated images.

Copy link

github-actions bot commented Nov 5, 2024

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +17.9Ki  +0.1% +16.0Ki    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-2989-compared-to-main.txt

Copy link

github-actions bot commented Nov 5, 2024

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0% +54.2Ki  +0.0% +15.8Ki    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2989-compared-to-main.txt

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +30% +34.6Mi  +433% +25.8Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2989-compared-to-legacy.txt

Copy link

github-actions bot commented Nov 5, 2024

Benchmark Results ⚡

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            -0.0135         -0.0134             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-2989-compared-to-main.txt

Copy link
Collaborator

@louwers louwers left a comment

Choose a reason for hiding this comment

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

Could you add a regression tests? Perhaps to the Android Instrumentation tests?

@louwers louwers added bug Something isn't working android labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants