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

Change runtime error to the nullptr returning #3184

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

TatyanaPolunina
Copy link
Collaborator

  • We are attempting to create shaders during the update of layers. It seems more appropriate to return a nullptr for a shader that fails to create, rather than stopping the app if one shader is not created (as exceptions are not caught).
  • Proper handling is implemented in all callers when a shader is nullptr, so we should not experience inconsistent behavior in such cases.
  • Most shader creation errors are related to low memory on iOS. Since we have lazy initialization for shaders, the behavior may be restored in the next level update if iOS frees the necessary memory.

Copy link
Collaborator

@adrian-cojocaru adrian-cojocaru left a comment

Choose a reason for hiding this comment

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

Returning null works, but on each subsequent call of getOrCreateShader the same shader creation will be retried and it can end up compiling the same code multiple times per frame.
An empty/debug "Null" shader should fix this, but I don't think the current checks can handle it.
Either way a performance hit is better than an unhandled exception.

@TatyanaPolunina
Copy link
Collaborator Author

Returning null works, but on each subsequent call of getOrCreateShader the same shader creation will be retried and it can end up compiling the same code multiple times per frame. An empty/debug "Null" shader should fix this, but I don't think the current checks can handle it. Either way a performance hit is better than an unhandled exception.

Potentially it could be even better. As shader is not created, that's why we have Null. Also we usually have "compile error" together with "memory warning" on IOS, so I expect that on next "updateLayers" IOS could clear the memory and we would correctly create shaders so app would work. But need to be investigated for sure

Copy link

github-actions bot commented Jan 31, 2025

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

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

Copy link

github-actions bot commented Jan 31, 2025

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

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

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +31% +36.1Mi  +438% +26.2Mi    TOTAL

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

Copy link

github-actions bot commented Jan 31, 2025

Benchmark Results ⚡

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            -0.0044         -0.0043             0             0             0             0

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

@TatyanaPolunina TatyanaPolunina merged commit e7bca28 into maplibre:main Feb 3, 2025
51 checks passed
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.

2 participants