fix(captures): serialize webgl requests to prevent memory leak when doing bulk captures and always clean up#37
Open
jnccloud wants to merge 3 commits into
Open
fix(captures): serialize webgl requests to prevent memory leak when doing bulk captures and always clean up#37jnccloud wants to merge 3 commits into
jnccloud wants to merge 3 commits into
Conversation
fix(webgl): serialize requests for webgl to accommodate for chromium …
Owner
|
Hi @jnccloud , thanks for the PR! Looks good! Could you please rebase your branch to the lastest upstream changes and then remove the fxmanifest change. No need to manually update the version |
There was a problem hiding this comment.
Pull request overview
This PR aims to improve stability during bulk screenshot capture by serializing capture requests (avoiding overlapping WebGL context usage) and ensuring capture resources are cleaned up more reliably to prevent memory/context leaks.
Changes:
- Serialize incoming
capturemessages via an internal promise queue to prevent concurrent WebGL captures. - Add
try/finallycleanup incaptureScreen()sodispose()/DOM cleanup runs even when capture/upload fails. - Bump resource version to
0.13.0-beta.2.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
game/nui/src/capture.ts |
Adds a capture queue and a try/finally cleanup path to reduce WebGL-context/memory issues during bulk capture. |
fxmanifest.lua |
Updates the resource version to 0.13.0-beta.2 (and minor formatting). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+97
to
+102
| } finally { | ||
| this.#gameView.dispose(); | ||
| this.#canvas.remove(); | ||
| this.#gameView = null; | ||
| this.#canvas = null; | ||
| } |
Comment on lines
77
to
+81
| this.#gameView = createGameView(this.#canvas); | ||
| this.#gameView.resize(width, height); | ||
|
|
||
| // Wait for the FiveM WebGL hook to populate the game framebuffer | ||
| await this.waitForFrames(3); | ||
| try { | ||
| // Wait for the FiveM WebGL hook to populate the game framebuffer |
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.
chromium by default only has 16 contexts and is supposed to handle it on its own, but I was running into frequent issues (out of game memory) and sluggish behavior during bulk capture sessions (aka green screens). this maintained my capture rate at about 1 per second for clothing items and I no longer suffered from out of game memory errors.