Skip to content

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!

@CodyJasonBennett CodyJasonBennett deleted the 23998-pick branch May 9, 2022 12:38
@Mugen87 Mugen87 modified the milestones: r141, r140 May 10, 2022
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
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