Skip to content

vello_hybrid: Properly clean up unused resources#1574

Open
LaurenzV wants to merge 1 commit into
mainfrom
laurenz/webgl
Open

vello_hybrid: Properly clean up unused resources#1574
LaurenzV wants to merge 1 commit into
mainfrom
laurenz/webgl

Conversation

@LaurenzV
Copy link
Copy Markdown
Collaborator

@LaurenzV LaurenzV commented Apr 14, 2026

Right now, an instance of a renderer creates a number of resources (vertex arrays, cached frame buffers), but they are never actually destroyed when the renderer is destroyed. This is usually not a huge problem because the browser garbage collector is likely to pick them up at some point, but it's still bad practice and there is no guarantee was to when this happens. I noticed this when trying vello_bench2 on my tablet, where I wanted to create a new fresh renderer for each benchmark, but at some point the browser would just crash. It is also a best practice to do so.

This PR proposes to create thin wrapper types around WebGL resources, where we add a Drop implementation that destroys them in WebGL. I admittedly haven't tested on my tablet whether this fixes it (because I switched vello_bench2 to a different approach), but conceptually this should work. 🤔 And it doesn't break the existing native_webgl example.

@LaurenzV LaurenzV requested a review from taj-p April 14, 2026 12:39
Copy link
Copy Markdown
Contributor

@taj-p taj-p left a comment

Choose a reason for hiding this comment

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

LGTM!!

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.

3 participants