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

GLTFExporter: Check for document before creating OffscreenCanvas #24035

Merged
merged 1 commit into from
May 9, 2022

Conversation

CodyJasonBennett
Copy link
Contributor

@CodyJasonBennett CodyJasonBennett commented May 9, 2022

Picked from #23998

Related issue: #23995

Description

This PR fixes a regression in GLTFExporter file sizes reported in #23995. It seems as if the OffscreenCanvas.convertToBlob function uses a 100% quality level by default in Blink powered browsers.

To fix this I've made two changes.

Check for the existence of document to identify if we are currently in a worker context. If we are, check for the existence of OffscreenCanvas and use it if it exists. If both are false, use the canvas API.
Infer default quality levels to pass to OffscreenCanvas.convertToBlob based on the given mimeType. Based on Blink's code the [default JPEG quality level](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/image-encoders/image_encoder.cc;l=85;drc=52f06e6b43ff95eccf79e0a5df8d4d83c029130a;bpv=0;bpt=1) should be 92% and the [default WebP quality](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/image-encoders/image_encoder.cc;l=100;drc=52f06e6b43ff95eccf79e0a5df8d4d83c029130a;bpv=0;bpt=1) should be 80%.

This contribution is funded by Matrix.org

Related: #24031

@mrdoob mrdoob added this to the r141 milestone May 9, 2022
@mrdoob mrdoob merged commit 4f0ff2c into mrdoob:dev May 9, 2022
@mrdoob
Copy link
Owner

mrdoob commented May 9, 2022

Thanks!

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.

None yet

3 participants