Repository navigation
Hold the current background until the next one is ready - #146
Conversation
Fixes #140. setBackgroundImage() writes bgTexture and customBackgroundImage only once the crop resolves, so a swap keeps showing the current image, and drops a crop whose image was replaced or cleared meanwhile. The transformer loads a new image before clearing the blur. With neither a blur nor an image, renderFrame composites against the frame itself, so a blur radius of 0 shows the camera instead of a black background.
🦋 Changeset detectedLatest commit: 8983e1e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
1egoman
left a comment
There was a problem hiding this comment.
Makes sense! Does this result in any change to the switching artifacts when jumping between blur and multiple background images? And are any e2e tests worth adding / updating as part of this? I see the test/webgl-pipeline.test.ts tests which seem to cover it pretty well but I'm unsure if there's anything alse that could be useful in the e2e suite.
I tested this manually with the e2e harness app and verified there's no flickering. Note that the corresponding PR is needed, otherwise there's a built-in flicker with the media reload. |
Summary
Fixes #140. A background change now takes effect only once the new background is ready. Until then, the current blur or image stays on screen. With neither a blur nor an image set, the composite shows the camera.
renderFrame: with no blur and no image, composites against the frame itself instead of whateverbgTexturelast held. A blur radius of 0 now shows the camera instead of a black background.setBackgroundImage: no longer clearscustomBackgroundImageor uploads the transparent placeholder when a change is requested. It sets and uploads the image only once the crop resolves, so swapping one image for another keeps the old image up until the new one lands. A crop whose image was replaced or cleared in the meantime, including bycleanup(), is dropped by comparing againstbackgroundSourceImage.setBlurRadius: no longer clears the image as a side effect.BackgroundTransformer.update(): loads the image before changing the blur, so blur → image keeps blurring until the image is ready instead of exposing the camera's own background. If a newerupdate()changesimagePathwhile the image is loading, the stale image is not applied and the newer blur is not cleared.This is the distinction the issue asks for: leaving image mode releases the image straight away, while replacing one image with another holds the old one until the new one is ready.
Measured
Every frame of the published track recorded across each transition with the e2e probe, with
createImageBitmapslowed by 300 ms to widen the loading window:Without the delay, both are clean in headless Chrome, because the harness images load and crop within one frame.
Tests
main.Not covered by a committed test: the transformer's reordering (blur stays up while an image loads). Testing it needs a per-frame e2e case with a slowed image load, like the recording above.