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 SVG image performance & scaling #4246

Open
BenHenning opened this issue Mar 14, 2022 · 1 comment
Open

Fix SVG image performance & scaling #4246

BenHenning opened this issue Mar 14, 2022 · 1 comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Issue: Needs Clarification Indicates that an issue needs more detail in order to be able to be acted upon. Work: High It's not clear what the solution is. Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@BenHenning
Copy link
Member

The fix in #4027 introduces DP-based scaling for images, and fixes some alignment/sizing issues. Unfortunately, these exposes a few problems:

  1. Sometimes upscaling SVGs on Android seems to result in a blurry image (which suggests rasterization happening under the surface). Since we use AndroidX for SVG rendering internally, it seems likely that this is happening (though I didn't confirm). Trying different scaling techniques didn't work, but I suspect that changing the Picture's dimensions during creation time in AndroidSVG to something large (e.g. by adding a configurable scalar that we can set from Oppia Android) might ensure the rasterization is correct. Note that blurry images will also be a problem for bitmaps since there's no upscaling going on, so we need to add that, too.
  2. SVG rendering generally seems slow, and using bitmaps (like we do for KitKat & Lollipop) doesn't actually fully fix the problem since it recomputes the bitmap on rebinding, and upscaling results in very large bitmaps that use up far too much app memory.

We want both upscaling and performant rendering for SVGs. I think that involves:

  1. Computing the smallest size necessary to render the image without it resulting in blurriness (which probably requires better understanding all the different scenarios an SVG can be rendered)
  2. Precomputing the bitmap and caching it via Glide (similar to what we do for LaTeX in Fix part of #4044: Add KotliTeX integration (direct LaTeX rendering) #4068) which should significantly improve performance. We do, however, need to make sure that any dependencies on display density are reflected in the caching message digest since the user changing the system's display zoom should result in recomputing the images (to ensure they don't waste space and/or end up blurry due to upscaling).
@Broppia Broppia added issue_type_bug Impact: Low Low perceived user impact (e.g. edge cases). labels Jun 2, 2022
@BenHenning
Copy link
Member Author

For searching context, this issue was found in 0.7-alpha (MR4).

@BenHenning BenHenning added this to the Beta MR2 milestone Jun 11, 2022
@BenHenning BenHenning added Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Issue: Needs Clarification Indicates that an issue needs more detail in order to be able to be acted upon. Z-ibt Temporary label for Ben to keep track of issues he's triaged. issue_user_learner and removed Impact: Low Low perceived user impact (e.g. edge cases). labels Sep 15, 2022
@BenHenning BenHenning removed this from the Beta MR2 milestone Sep 16, 2022
@seanlip seanlip added bug End user-perceivable behaviors which are not desirable. and removed issue_type_bug labels Mar 28, 2023
@seanlip seanlip removed the user_team label Mar 30, 2023
@adhiamboperes adhiamboperes added the Work: High It's not clear what the solution is. label Jul 9, 2023
@adhiamboperes adhiamboperes added this to the 1.0 Global availability milestone Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Issue: Needs Clarification Indicates that an issue needs more detail in order to be able to be acted upon. Work: High It's not clear what the solution is. Z-ibt Temporary label for Ben to keep track of issues he's triaged.
Development

No branches or pull requests

4 participants