perf: gallery virtualization#3675
Merged
Merged
Conversation
isekovanic
commented
Jun 23, 2026
isekovanic
commented
Jun 23, 2026
Contributor
SDK Size
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Our image gallery was never properly virtualized and mounted one slide component per asset for all loaded media (
assets.map(...)), so scroll/swipe jank scaled with the asset count. On a media heavy channel roughly 40% of frames were janky, driven byO(N)animated style worklets rerunning on the UI thread every frame. This bounds that cost so gallery performance no longer degrades as channels accumulate media. This was relatively fine before, whenChannelDetailshadn't been introduced yet but now poses an actual challenge.🛠 Implementation details
GalleryPagerthat mounts only the slides withinPAGER_WINDOW_RADIUSof the current index, instead of all N. Mounted slides drop from ~N to ~9.useAnimatedGalleryStyle) are a pure function ofindex+flexposition, so windowing the mount should be fineGalleryPagersubscribes tocurrentIndexitself, so paging rerenders only the small slide list, never the parent (gesture objects/GestureDetectorstay stable).shouldRenderload gate is retained (image +-3, video +-1) for now so windowing bounds the mount;shouldRenderstill bounds content load (notably capping live native video players within the mounted set).Measured on a debug
SampleApp(on a media heavy channel), provided below are the results (naturally, taken from the best 5 runs against baseline and the worst 5 runs against this branch across of many, many runs):Jank no longer scales with asset count (after jank is flat across N, where before it rose).
🎨 UI Changes
iOS
Android
🧪 Testing
☑️ Checklist
developbranch