diff --git a/packages/fiber/src/core/index.tsx b/packages/fiber/src/core/index.tsx index c23fd7e4d8..f505537129 100644 --- a/packages/fiber/src/core/index.tsx +++ b/packages/fiber/src/core/index.tsx @@ -126,17 +126,21 @@ export type ReconcilerRoot = { } function computeInitialSize(canvas: Canvas, defaultSize?: Size): Size { - if (defaultSize) return defaultSize + const defaultStyle = typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement - if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) { + if (defaultSize) { + const { width, height, top, left, updateStyle = defaultStyle } = defaultSize + return { width, height, top, left, updateStyle } + } else if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) { const { width, height, top, left } = canvas.parentElement.getBoundingClientRect() - return { width, height, top, left } + return { width, height, top, left, updateStyle: defaultStyle } } else if (typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) { return { width: canvas.width, height: canvas.height, top: 0, left: 0, + updateStyle: defaultStyle, } } diff --git a/packages/fiber/src/core/store.ts b/packages/fiber/src/core/store.ts index 920c8b43a5..96ebb10896 100644 --- a/packages/fiber/src/core/store.ts +++ b/packages/fiber/src/core/store.ts @@ -338,7 +338,7 @@ const createStore = ( const { camera, size, viewport, gl, set } = rootState.getState() // Resize camera and renderer on changes to size and pixelratio - if (size !== oldSize || viewport.dpr !== oldDpr) { + if (size.width !== oldSize.width || size.height !== oldSize.height || viewport.dpr !== oldDpr) { oldSize = size oldDpr = viewport.dpr // Update camera & renderer