Repository navigation
Conversation
…ontext loss InternalTexture._rebuild re-uploads the dynamic texture source with the stored invertY/premulAlpha, but DynamicTexture._rebuild then called update() with no arguments, which uploads again with invertY = true and premulAlpha = false. A texture updated with invertY = false came back flipped after a context restore (WebGL and WebGPU). Reuse the values the internal texture recorded on the last update(). A texture that was never updated keeps the old behavior. Fixes BabylonJS#19164
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
deltakosh
left a comment
There was a problem hiding this comment.
Hello @vladosskins178,
The fix is right. Both the WebGL and WebGPU updateDynamicTexture store _dynamicTextureSource, _premulAlpha and invertY on the internal texture, so replaying them in _rebuild() matches what InternalTexture._rebuild() re-uploads. The _dynamicTextureSource guard keeps never-updated textures, and Native (which doesn't set it), on the old path.
One thing in the tests. "uses the update defaults when the texture was never updated" hard-codes update()'s defaults (true / false), and the second test does the same for the premulAlpha default. If those defaults ever change, the tests break without the behavior being wrong. For the never-updated case, please assert that _rebuild() calls update() with no arguments (spy on texture.update) instead of copying its defaults. For the second test, pass premulAlpha explicitly (update(true, false)) so the expectation comes from the test's own input.
Thanks!
…ults The never-updated case now checks that _rebuild() calls update() with no arguments, and the invertY = true case passes premulAlpha explicitly.
|
Thanks, done in f5d8125. The never-updated test now spies on |
Popov72
left a comment
There was a problem hiding this comment.
Complete read-only review of the context-restoration fix, backend metadata preservation, GUI integration, and regression tests found no actionable issues.
deltakosh
left a comment
There was a problem hiding this comment.
Re-reviewed the incremental change at f5d8125.
Both test points are addressed: the never-updated case now asserts _rebuild() calls update() with no arguments, and the second test passes premulAlpha explicitly, so every expectation comes from the test's own inputs. The fix itself is unchanged and still correct. Approving.
Thanks!
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 5 pipeline(s) were filtered out due to trigger conditions. |
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/19167/merge/index.html#WGZLGJ#4600 Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves): https://playground.babylonjs.com/?snapshot=refs/pull/19167/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/19167/merge#BCU1XR#0 If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools. |
🟢 Memory Leak Test Results4 passed, 0 leaked out of 4 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (4)
|
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
Fixes #19164
A
DynamicTextureupdated withinvertY = falsecomes back flipped after a context loss and restore.Cause: on restore,
InternalTexture._rebuild()re-uploads_dynamicTextureSourcewith the storedinvertYand_premulAlpha. ThenDynamicTexture._rebuild()callsupdate()with no arguments, which uploads again withinvertY = trueandpremulAlpha = falseand overwrites the correct upload.Fix:
_rebuild()passes theinvertYand_premulAlphathat the engine recorded on the internal texture during the lastupdate(). A texture that was never updated keeps the old behavior (update()defaults).AdvancedDynamicTexturegoes through the same_rebuild(), soapplyYInversionOnUpdate = false/premulAlphanow survive a restore too.Tests: new
dynamicTexture.rebuild.test.ts(NullEngine,updateDynamicTexturespied):(false, true)→ rebuild uploads(false, true)(fails on master: uploadstrue, false)(true)→ rebuild uploads(true, false)update()defaultsUnit tests for
Materials/Textures,Enginesandgui: 74 files, 752 passed. eslint, prettier andtsc -p packages/dev/core/tsconfig.build.jsonare clean.Checked in a browser: Chromium (WebGL2, SwiftShader), the gradient repro from the issue on a plane, 9.35.0 from the CDN,
WEBGL_lose_contextlose/restore, reading the top pixel:[5,0,249], after restore[250,0,6](flipped)_rebuild(): before[5,0,249], after restore[5,0,249]update(true)both versions stay the same before and after.