fix(core): Correctly resize drawing buffer on resize#9886
fix(core): Correctly resize drawing buffer on resize#9886felixpalmer merged 3 commits intomasterfrom
Conversation
|
This improves the typical resize window case for me! There remains an issue where moving to a window with a different DPR doesn't trigger a resize / redraw. Here's from high to low DPR: high.to.low.dpr.2.mov
Luma also provides a #9877 had some combination of observation/redrawing/property updates that worked |
deck.gl/modules/mapbox/src/mapbox-overlay.ts Line 143 in 88fdd61 Mapbox interleaved modes has |
|
I do see the callbacks firing when |
The resize callbacks don't fire with an interleaved overlay because they supply an external gl context, and that path uses deck.gl/modules/core/src/lib/deck.ts Lines 369 to 372 in 2dc5d9a This means:
|
|
I ran through 15 test cases - resizing the window and moving them between monitors - and compiled my findings in #9887. I recommend we merge those changes into this PR. The differences are:
|
| if (this.device?.canvasContext && this.device?.canvasContext.props.autoResize === false) { | ||
| const {width, height} = this.device.canvasContext.canvas; | ||
| this.device.canvasContext?.setDrawingBufferSize(width, height); |
There was a problem hiding this comment.
Putting this in setProps means it only updates when props change. Why not add onResize callback to the attach device props instead so that it updates the drawing buffer when a resize event occurs? See #9887
|
Thanks @felixpalmer ! |
|
Thanks @chrisgervang @akre54 for the extensive testing. I'm merging this as is, in the interest of having small granular PRs |

Closes #9856 #9666.
Replaces #9877 & includes #9870
Background
Upgrading to luma@9.2 introduced
CanvasContextas a new way of handling browser resizing. There are two area which were not implementing in deck to work with the new design in luma.gl:onResizecallback was not registeredsetDrawingBufferSizenever invoked (important in interleaved case whereautoResize = falseI've verified with these changes that resizing is working in the following examples:
get-started/pure-js/google-mapsget-started/react/google-mapsget-started/pure-js/maplibreget-started/react/maplibreIn each case I tested both interleaved
trueandfalse. All 8 variants are working with these fixes.Change List
_needsRedrawwhenCanvasContext.onResize()is calledautoResize = falseNote
Trigger redraw on CanvasContext resize and keep drawing buffer in sync (including when autoResize=false), while routing useDevicePixels via CanvasContext.
onResizewith luma device to set_needsRedraw = 'Canvas resized', then call any useronResize.autoResize === false, callcanvasContext.setDrawingBufferSize(width, height)to sync drawing buffer with canvas.useDevicePixelsviacanvasContext.setProps({useDevicePixels})instead of manual resize hack.deviceProps.onResizeafter internal handler.useDevicePixelsandautoResize: truetocreateCanvasContext.Written by Cursor Bugbot for commit 562bc72. This will update automatically on new commits. Configure here.