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

[WebglGraphicsDevice] Catch and return async error in readTextureAsync #7173

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

liamdon
Copy link
Contributor

@liamdon liamdon commented Dec 4, 2024

Very small change to WebglGraphicsDevice which catches and calls reject when readPixelsAsync fails.

We saw this failure while attempting a readback during WebGL context loss, or if a context loss occurs while async reading is in progress.

Without this change, the method throws an uncaught exception that cannot be caught in any downstream APIs, for example:

myTexture
    .read(0, 0, myTexture.width, myTexture.height, { mipLevel: 0 })
    .then((pixels) => {
        // All is well
    }).catch((err) -> {
        // Will never be called on error
    });

With this change, the code above will work as expected and allow the developer to handle any readback errors as they see fit.

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

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

awesome, thanks!

@mvaligursky mvaligursky merged commit 2fdb5ab into playcanvas:main Dec 5, 2024
8 checks passed
slimbuck pushed a commit that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants