Skip to content

Commit 87cd3f4

Browse files
authored
Merge pull request #106 from vchelaru/fix/105-splitter-magenta-flash
Fix magenta canvas flash while dragging the splitter (#105)
2 parents 988edeb + 2acfde1 commit 87cd3f4

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

XnaFiddle.BlazorGL/wwwroot/index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,20 @@
129129
// Subtract remainder to avoid drift accumulating over time
130130
window._lastTickTime = now - (elapsed % window._tickInterval);
131131
}
132-
// Sync canvas drawing buffer to its container each frame
132+
// Sync canvas drawing buffer to its container each frame — but NOT while a splitter is
133+
// being dragged (issue #105). Assigning canvas.width/height REALLOCATES the WebGL drawing
134+
// buffer, and on Windows Chrome (ANGLE -> D3D11) a fresh buffer is filled with magenta as
135+
// its uninitialized pattern. Normally invisible because the game's Draw repaints it that
136+
// same frame — but a splitter drag changes the holder size every frame while the game step
137+
// may be skipped (touch, _uiDragging) or lag the resize, so the raw magenta buffer shows
138+
// through for the whole drag. Instead we let the last-good buffer stretch via CSS
139+
// (#theCanvas is width/height:100% of the holder) during the drag — slightly soft — and
140+
// reallocate once on drag-end: the first tick after _uiDragging clears sees the size
141+
// mismatch below and snaps the buffer crisp. This also removes the per-frame realloc +
142+
// OnCanvasResized churn during a drag. Both splitter handlers set _uiDragging.
133143
var canvas = document.getElementById('theCanvas');
134144
var holder = document.getElementById('canvasHolder');
135-
if (canvas && holder) {
145+
if (canvas && holder && !window._uiDragging) {
136146
var w = holder.clientWidth;
137147
var h = holder.clientHeight;
138148
if (canvas.width !== w || canvas.height !== h) {

0 commit comments

Comments
 (0)