Skip to content

feat: common.attachAutoResizer#2534

Open
iwoplaza wants to merge 8 commits into
mainfrom
feat/resize-common
Open

feat: common.attachAutoResizer#2534
iwoplaza wants to merge 8 commits into
mainfrom
feat/resize-common

Conversation

@iwoplaza

@iwoplaza iwoplaza commented May 21, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a new common helper called attachAutoResizer which adapts the canvas' internal resolution to match its physical pixel size, with additional safe-guards. It's a web only helper, not to be used in React Native apps.

The examples were updated to use this helper, which replaces the need for the example environment to handle the canvas resizing. This also makes the examples much more portable, as resizing a canvas can be tricky to get right, and now it's solved in every example.

@iwoplaza iwoplaza added this to the 0.11.5 milestone May 21, 2026
@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@c59c2a7641cf8479edca7a30544aa2b5519b2da4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@c59c2a7641cf8479edca7a30544aa2b5519b2da4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@c59c2a7641cf8479edca7a30544aa2b5519b2da4
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@c59c2a7641cf8479edca7a30544aa2b5519b2da4
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@c59c2a7641cf8479edca7a30544aa2b5519b2da4

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

📊 Bundle Size Comparison

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
0 355 1 0

👀 Notable results

Static test results:

No major changes.

Dynamic test results:

Test tsdown
common from typegpu.ts 59.05 kB ($${\color{red}+1.1\%}$$)

📋 All results

Click to reveal the results table (355 entries).
Test tsdown
common from typegpu.ts 59.05 kB ($${\color{red}+1.1\%}$$)
dataImportEverything.ts 89.49 kB (➖)
dataImportOneDirect.ts 24.62 kB (➖)
dataImportOneStar.ts 24.62 kB (➖)
functionWithUseGpu.ts 282 B (➖)
functionWithoutUseGpu.ts 24 B (➖)
importEntireLibrary.ts 289.26 kB (➖)
stdImportEverything.ts 105.73 kB (➖)
stdImportOneDirect.ts 48.37 kB (➖)
stdImportOneStar.ts 48.37 kB (➖)
tgpuImportEverything.ts 261.40 kB (➖)
tgpuImportOne.ts 261.41 kB (➖)
MissingBindGroupsError from typegpu.ts 1.35 kB (➖)
MissingSlotValueError from typegpu.ts 151 B (➖)
MissingVertexBuffersError from typegpu.ts 1.36 kB (➖)
NotUniformError from typegpu.ts 1.31 kB (➖)
ResolutionError from typegpu.ts 2.33 kB (➖)
ShaderGenerator from typegpu.ts 1.66 kB (➖)
Void from typegpudata.ts 734 B (➖)
WgslGenerator from typegpu.ts 114.87 kB (➖)
abs from typegpustd.ts 65.82 kB (➖)
acos from typegpustd.ts 65.82 kB (➖)
acosh from typegpustd.ts 65.82 kB (➖)
add from typegpustd.ts 48.37 kB (➖)
align from typegpudata.ts 26.31 kB (➖)
alignmentOf from typegpudata.ts 21.85 kB (➖)
allEq from typegpustd.ts 51.74 kB (➖)
all from typegpustd.ts 51.74 kB (➖)
and from typegpustd.ts 51.74 kB (➖)
any from typegpustd.ts 51.75 kB (➖)
arrayLength from typegpustd.ts 14.43 kB (➖)
arrayOf from typegpudata.ts 26.17 kB (➖)
asin from typegpustd.ts 65.82 kB (➖)
asinh from typegpustd.ts 65.82 kB (➖)
atan2 from typegpustd.ts 65.82 kB (➖)
atan from typegpustd.ts 65.82 kB (➖)
atanh from typegpustd.ts 65.82 kB (➖)
atomicAdd from typegpustd.ts 15.80 kB (➖)
atomicAnd from typegpustd.ts 15.80 kB (➖)
atomicLoad from typegpustd.ts 15.79 kB (➖)
atomicMax from typegpustd.ts 15.80 kB (➖)
atomicMin from typegpustd.ts 15.80 kB (➖)
atomicOr from typegpustd.ts 15.80 kB (➖)
atomicStore from typegpustd.ts 15.79 kB (➖)
atomicSub from typegpustd.ts 15.80 kB (➖)
atomicXor from typegpustd.ts 15.80 kB (➖)
atomic from typegpudata.ts 779 B (➖)
bitShiftLeft from typegpustd.ts 48.37 kB (➖)
bitShiftRight from typegpustd.ts 48.37 kB (➖)
bitcastU32toF32 from typegpustd.ts 44.19 kB (➖)
bitcastU32toI32 from typegpustd.ts 44.20 kB (➖)
bool from typegpudata.ts 12.97 kB (➖)
builtin from typegpudata.ts 28.63 kB (➖)
ceil from typegpustd.ts 65.82 kB (➖)
clamp from typegpustd.ts 65.82 kB (➖)
comparisonSampler from typegpudata.ts 753 B (➖)
copy from typegpustd.ts 14.43 kB (➖)
cos from typegpustd.ts 65.82 kB (➖)
cosh from typegpustd.ts 65.82 kB (➖)
countLeadingZeros from typegpustd.ts 65.82 kB (➖)
countOneBits from typegpustd.ts 65.82 kB (➖)
countTrailingZeros from typegpustd.ts 65.82 kB (➖)
cross from typegpustd.ts 65.82 kB (➖)
d from typegpu.ts 87.17 kB (➖)
deepEqual from typegpudata.ts 2.19 kB (➖)
degrees from typegpustd.ts 65.82 kB (➖)
determinant from typegpustd.ts 65.82 kB (➖)
disarrayOf from typegpudata.ts 15.02 kB (➖)
discard from typegpustd.ts 14.19 kB (➖)
distance from typegpustd.ts 65.82 kB (➖)
div from typegpustd.ts 48.37 kB (➖)
dot4I8Packed from typegpustd.ts 65.82 kB (➖)
dot4U8Packed from typegpustd.ts 65.82 kB (➖)
dot from typegpustd.ts 65.81 kB (➖)
dpdxCoarse from typegpustd.ts 15.04 kB (➖)
dpdxFine from typegpustd.ts 15.04 kB (➖)
dpdx from typegpustd.ts 15.03 kB (➖)
dpdyCoarse from typegpustd.ts 15.04 kB (➖)
dpdyFine from typegpustd.ts 15.04 kB (➖)
dpdy from typegpustd.ts 15.04 kB (➖)
eq from typegpustd.ts 51.74 kB (➖)
exp2 from typegpustd.ts 65.82 kB (➖)
exp from typegpustd.ts 65.82 kB (➖)
extensionEnabled from typegpustd.ts 14.58 kB (➖)
extractBits from typegpustd.ts 65.82 kB (➖)
f16 from typegpudata.ts 12.97 kB (➖)
f32 from typegpudata.ts 12.97 kB (➖)
faceForward from typegpustd.ts 65.82 kB (➖)
firstLeadingBit from typegpustd.ts 65.82 kB (➖)
firstTrailingBit from typegpustd.ts 65.82 kB (➖)
float16 from typegpudata.ts 20.91 kB (➖)
float16x2 from typegpudata.ts 20.91 kB (➖)
float16x4 from typegpudata.ts 20.91 kB (➖)
float32 from typegpudata.ts 20.91 kB (➖)
float32x2 from typegpudata.ts 20.91 kB (➖)
float32x3 from typegpudata.ts 20.91 kB (➖)
float32x4 from typegpudata.ts 20.91 kB (➖)
floor from typegpustd.ts 65.82 kB (➖)
fma from typegpustd.ts 65.82 kB (➖)
formatToWGSLType from typegpudata.ts 20.90 kB (➖)
fract from typegpustd.ts 65.82 kB (➖)
frexp from typegpustd.ts 65.82 kB (➖)
fwidthCoarse from typegpustd.ts 15.04 kB (➖)
fwidthFine from typegpustd.ts 15.04 kB (➖)
fwidth from typegpustd.ts 15.04 kB (➖)
ge from typegpustd.ts 51.75 kB (➖)
getLongestContiguousPrefix from typegpudata.ts 24.64 kB (➖)
getTargetShaderLanguage from typegpustd.ts 14.53 kB (➖)
gt from typegpustd.ts 51.75 kB (➖)
i32 from typegpudata.ts 12.97 kB (➖)
identity2 from typegpustd.ts 26.99 kB (➖)
identity3 from typegpustd.ts 26.99 kB (➖)
identity4 from typegpustd.ts 26.99 kB (➖)
insertBits from typegpustd.ts 65.82 kB (➖)
interpolate from typegpudata.ts 26.32 kB (➖)
invariant from typegpudata.ts 26.69 kB (➖)
inverseSqrt from typegpustd.ts 65.82 kB (➖)
isAccessor from typegpu.ts 65 B (➖)
isAlignAttrib from typegpudata.ts 755 B (➖)
isAtomic from typegpudata.ts 755 B (➖)
isBeingTranspiled from typegpustd.ts 14.47 kB (➖)
isBufferShorthand from typegpu.ts 1.71 kB (➖)
isBuffer from typegpu.ts 88.51 kB (➖)
isBuiltinAttrib from typegpudata.ts 757 B (➖)
isBuiltin from typegpudata.ts 24.57 kB (➖)
isCloseTo from typegpustd.ts 51.75 kB (➖)
isComparisonSampler from typegpu.ts 62.96 kB (➖)
isContiguous from typegpudata.ts 24.63 kB (➖)
isData from typegpudata.ts 1.81 kB (➖)
isDecorated from typegpudata.ts 758 B (➖)
isDisarray from typegpudata.ts 1.11 kB (➖)
isInterpolateAttrib from typegpudata.ts 761 B (➖)
isLazy from typegpu.ts 61 B (➖)
isLocationAttrib from typegpudata.ts 758 B (➖)
isLooseData from typegpudata.ts 1.16 kB (➖)
isLooseDecorated from typegpudata.ts 1.12 kB (➖)
isMutableAccessor from typegpu.ts 73 B (➖)
isPackedData from typegpudata.ts 20.97 kB (➖)
isPtr from typegpudata.ts 752 B (➖)
isSampler from typegpu.ts 62.95 kB (➖)
isSizeAttrib from typegpudata.ts 754 B (➖)
isSlot from typegpu.ts 61 B (➖)
isTexture from typegpu.ts 62.94 kB (➖)
isTgpuComputeFn from typegpu.ts 69 B (➖)
isTgpuFn from typegpu.ts 765 B (➖)
isTgpuFragmentFn from typegpu.ts 70 B (➖)
isTgpuVertexFn from typegpu.ts 68 B (➖)
isUnstruct from typegpudata.ts 1.11 kB (➖)
isUsableAsRender from typegpu.ts 55 B (➖)
isUsableAsSampled from typegpu.ts 56 B (➖)
isUsableAsStorage from typegpu.ts 56 B (➖)
isUsableAsUniform from typegpu.ts 62.93 kB (➖)
isUsableAsVertex from typegpu.ts 88.50 kB (➖)
isVariable from typegpu.ts 64.65 kB (➖)
isWgslArray from typegpudata.ts 754 B (➖)
isWgslData from typegpudata.ts 1.31 kB (➖)
isWgslStruct from typegpudata.ts 755 B (➖)
ldexp from typegpustd.ts 65.82 kB (➖)
le from typegpustd.ts 51.75 kB (➖)
length from typegpustd.ts 65.81 kB (➖)
location from typegpudata.ts 26.31 kB (➖)
log2 from typegpustd.ts 65.82 kB (➖)
log from typegpustd.ts 65.82 kB (➖)
lt from typegpustd.ts 51.74 kB (➖)
mat2x2f from typegpudata.ts 26.99 kB (➖)
mat3x3f from typegpudata.ts 26.99 kB (➖)
mat4x4f from typegpudata.ts 26.99 kB (➖)
matToArray from typegpudata.ts 27.12 kB (➖)
max from typegpustd.ts 65.82 kB (➖)
memoryLayoutOf from typegpudata.ts 41.95 kB (➖)
min from typegpustd.ts 65.82 kB (➖)
mix from typegpustd.ts 65.82 kB (➖)
mod from typegpustd.ts 48.37 kB (➖)
modf from typegpustd.ts 65.82 kB (➖)
mul from typegpustd.ts 48.37 kB (➖)
ne from typegpustd.ts 51.74 kB (➖)
neg from typegpustd.ts 48.36 kB (➖)
normalize from typegpustd.ts 65.82 kB (➖)
not from typegpustd.ts 51.74 kB (➖)
or from typegpustd.ts 51.74 kB (➖)
pack2x16float from typegpustd.ts 35.94 kB (➖)
pack4x8unorm from typegpustd.ts 35.94 kB (➖)
packedFormats from typegpudata.ts 20.92 kB (➖)
patchArrayBuffer from typegpu.ts 51.09 kB (➖)
pow from typegpustd.ts 65.82 kB (➖)
ptrFn from typegpudata.ts 859 B (➖)
ptrHandle from typegpudata.ts 851 B (➖)
ptrPrivate from typegpudata.ts 858 B (➖)
ptrStorage from typegpudata.ts 856 B (➖)
ptrUniform from typegpudata.ts 852 B (➖)
ptrWorkgroup from typegpudata.ts 860 B (➖)
quantizeToF16 from typegpustd.ts 65.82 kB (➖)
radians from typegpustd.ts 65.82 kB (➖)
range from typegpustd.ts 14.85 kB (➖)
readFromArrayBuffer from typegpu.ts 51.69 kB (➖)
ref from typegpudata.ts 4.79 kB (➖)
reflect from typegpustd.ts 65.82 kB (➖)
refract from typegpustd.ts 65.82 kB (➖)
reverseBits from typegpustd.ts 65.82 kB (➖)
rotateX4 from typegpustd.ts 49.13 kB (➖)
rotateY4 from typegpustd.ts 49.13 kB (➖)
rotateZ4 from typegpustd.ts 49.13 kB (➖)
rotationX4 from typegpustd.ts 26.99 kB (➖)
rotationY4 from typegpustd.ts 26.99 kB (➖)
rotationZ4 from typegpustd.ts 26.99 kB (➖)
round from typegpustd.ts 65.82 kB (➖)
sampler from typegpudata.ts 742 B (➖)
saturate from typegpustd.ts 65.82 kB (➖)
scale4 from typegpustd.ts 49.13 kB (➖)
scaling4 from typegpustd.ts 26.99 kB (➖)
select from typegpustd.ts 51.74 kB (➖)
sign from typegpustd.ts 65.82 kB (➖)
sin from typegpustd.ts 65.82 kB (➖)
sinh from typegpustd.ts 65.82 kB (➖)
sint16 from typegpudata.ts 20.91 kB (➖)
sint16x2 from typegpudata.ts 20.91 kB (➖)
sint16x4 from typegpudata.ts 20.91 kB (➖)
sint32 from typegpudata.ts 20.91 kB (➖)
sint32x2 from typegpudata.ts 20.91 kB (➖)
sint32x3 from typegpudata.ts 20.91 kB (➖)
sint32x4 from typegpudata.ts 20.91 kB (➖)
sint8 from typegpudata.ts 20.91 kB (➖)
sint8x2 from typegpudata.ts 20.91 kB (➖)
sint8x4 from typegpudata.ts 20.91 kB (➖)
sizeOf from typegpudata.ts 24.62 kB (➖)
size from typegpudata.ts 26.31 kB (➖)
smoothstep from typegpustd.ts 65.82 kB (➖)
snorm16 from typegpudata.ts 20.91 kB (➖)
snorm16x2 from typegpudata.ts 20.91 kB (➖)
snorm16x4 from typegpudata.ts 20.91 kB (➖)
snorm8 from typegpudata.ts 20.91 kB (➖)
snorm8x2 from typegpudata.ts 20.91 kB (➖)
snorm8x4 from typegpudata.ts 20.91 kB (➖)
sqrt from typegpustd.ts 65.82 kB (➖)
std from typegpu.ts 102.89 kB (➖)
step from typegpustd.ts 65.82 kB (➖)
storageBarrier from typegpustd.ts 15.80 kB (➖)
struct from typegpudata.ts 3.42 kB (➖)
sub from typegpustd.ts 48.37 kB (➖)
subgroupAdd from typegpustd.ts 23.98 kB (➖)
subgroupAll from typegpustd.ts 23.99 kB (➖)
subgroupAnd from typegpustd.ts 23.99 kB (➖)
subgroupAny from typegpustd.ts 23.99 kB (➖)
subgroupBallot from typegpustd.ts 23.99 kB (➖)
subgroupBroadcastFirst from typegpustd.ts 23.99 kB (➖)
subgroupBroadcast from typegpustd.ts 23.99 kB (➖)
subgroupElect from typegpustd.ts 23.99 kB (➖)
subgroupExclusiveAdd from typegpustd.ts 23.99 kB (➖)
subgroupExclusiveMul from typegpustd.ts 23.99 kB (➖)
subgroupInclusiveAdd from typegpustd.ts 23.99 kB (➖)
subgroupInclusiveMul from typegpustd.ts 23.99 kB (➖)
subgroupMax from typegpustd.ts 23.99 kB (➖)
subgroupMin from typegpustd.ts 23.99 kB (➖)
subgroupMul from typegpustd.ts 23.99 kB (➖)
subgroupOr from typegpustd.ts 23.99 kB (➖)
subgroupShuffleDown from typegpustd.ts 23.99 kB (➖)
subgroupShuffleUp from typegpustd.ts 23.99 kB (➖)
subgroupShuffleXor from typegpustd.ts 23.99 kB (➖)
subgroupShuffle from typegpustd.ts 23.99 kB (➖)
subgroupXor from typegpustd.ts 23.99 kB (➖)
tan from typegpustd.ts 65.82 kB (➖)
tanh from typegpustd.ts 65.82 kB (➖)
texture1d from typegpudata.ts 13.43 kB (➖)
texture2dArray from typegpudata.ts 13.45 kB (➖)
texture2d from typegpudata.ts 13.43 kB (➖)
texture3d from typegpudata.ts 13.43 kB (➖)
textureBarrier from typegpustd.ts 15.79 kB (➖)
textureCubeArray from typegpudata.ts 13.45 kB (➖)
textureCube from typegpudata.ts 13.43 kB (➖)
textureDepth2dArray from typegpudata.ts 13.44 kB (➖)
textureDepth2d from typegpudata.ts 13.42 kB (➖)
textureDepthCubeArray from typegpudata.ts 13.44 kB (➖)
textureDepthCube from typegpudata.ts 13.42 kB (➖)
textureDepthMultisampled2d from typegpudata.ts 13.44 kB (➖)
textureDimensions from typegpustd.ts 25.74 kB (➖)
textureExternal from typegpudata.ts 873 B (➖)
textureGather from typegpustd.ts 25.74 kB (➖)
textureLoad from typegpustd.ts 25.75 kB (➖)
textureMultisampled2d from typegpudata.ts 13.45 kB (➖)
textureSampleBaseClampToEdge from typegpustd.ts 25.75 kB (➖)
textureSampleBias from typegpustd.ts 25.75 kB (➖)
textureSampleCompareLevel from typegpustd.ts 25.75 kB (➖)
textureSampleCompare from typegpustd.ts 25.75 kB (➖)
textureSampleGrad from typegpustd.ts 25.75 kB (➖)
textureSampleLevel from typegpustd.ts 25.75 kB (➖)
textureSample from typegpustd.ts 25.75 kB (➖)
textureStorage1d from typegpudata.ts 1.01 kB (➖)
textureStorage2dArray from typegpudata.ts 1.03 kB (➖)
textureStorage2d from typegpudata.ts 1.01 kB (➖)
textureStorage3d from typegpudata.ts 1.01 kB (➖)
textureStore from typegpustd.ts 25.75 kB (➖)
tgpu.accessor from typegpu.ts 261.41 kB (➖)
tgpu.bindGroupLayout from typegpu.ts 261.42 kB (➖)
tgpu.comptime from typegpu.ts 261.41 kB (➖)
tgpu.computeFn from typegpu.ts 261.41 kB (➖)
tgpu.const from typegpu.ts 261.41 kB (➖)
tgpu.fn from typegpu.ts 261.41 kB (➖)
tgpu.fragmentFn from typegpu.ts 261.41 kB (➖)
tgpu.initFromDevice from typegpu.ts 261.42 kB (➖)
tgpu.init from typegpu.ts 261.41 kB (➖)
tgpu.lazy from typegpu.ts 261.41 kB (➖)
tgpu.mutableAccessor from typegpu.ts 261.42 kB (➖)
tgpu.privateVar from typegpu.ts 261.41 kB (➖)
tgpu.resolveWithContext from typegpu.ts 261.42 kB (➖)
tgpu.resolve from typegpu.ts 261.41 kB (➖)
tgpu.slot from typegpu.ts 261.41 kB (➖)
tgpu.unroll from typegpu.ts 261.41 kB (➖)
tgpu.vertexFn from typegpu.ts 261.41 kB (➖)
tgpu.vertexLayout from typegpu.ts 261.42 kB (➖)
tgpu.workgroupVar from typegpu.ts 261.42 kB (➖)
tgpu from typegpu.ts 261.40 kB (➖)
translate4 from typegpustd.ts 49.13 kB (➖)
translation4 from typegpustd.ts 26.99 kB (➖)
transpose from typegpustd.ts 65.82 kB (➖)
trunc from typegpustd.ts 65.82 kB (➖)
u16 from typegpudata.ts 13.00 kB (➖)
u32 from typegpudata.ts 12.97 kB (➖)
uint16 from typegpudata.ts 20.91 kB (➖)
uint16x2 from typegpudata.ts 20.91 kB (➖)
uint16x4 from typegpudata.ts 20.91 kB (➖)
uint32 from typegpudata.ts 20.91 kB (➖)
uint32x2 from typegpudata.ts 20.91 kB (➖)
uint32x3 from typegpudata.ts 20.91 kB (➖)
uint32x4 from typegpudata.ts 20.91 kB (➖)
uint8 from typegpudata.ts 20.90 kB (➖)
uint8x2 from typegpudata.ts 20.91 kB (➖)
uint8x4 from typegpudata.ts 20.91 kB (➖)
unorm10 10 10 2 from typegpudata.ts 20.91 kB (➖)
unorm16 from typegpudata.ts 20.91 kB (➖)
unorm16x2 from typegpudata.ts 20.91 kB (➖)
unorm16x4 from typegpudata.ts 20.91 kB (➖)
unorm8 from typegpudata.ts 20.91 kB (➖)
unorm8x2 from typegpudata.ts 20.91 kB (➖)
unorm8x4 bgra from typegpudata.ts 20.91 kB (➖)
unorm8x4 from typegpudata.ts 20.91 kB (➖)
unpack2x16float from typegpustd.ts 35.94 kB (➖)
unpack4x8unorm from typegpustd.ts 35.94 kB (➖)
unstruct from typegpudata.ts 1.55 kB (➖)
vec2b from typegpudata.ts 19.41 kB (➖)
vec2f from typegpudata.ts 19.41 kB (➖)
vec2h from typegpudata.ts 19.41 kB (➖)
vec2i from typegpudata.ts 19.41 kB (➖)
vec2u from typegpudata.ts 19.41 kB (➖)
vec3b from typegpudata.ts 19.41 kB (➖)
vec3f from typegpudata.ts 19.41 kB (➖)
vec3h from typegpudata.ts 19.41 kB (➖)
vec3i from typegpudata.ts 19.41 kB (➖)
vec3u from typegpudata.ts 19.41 kB (➖)
vec4b from typegpudata.ts 19.41 kB (➖)
vec4f from typegpudata.ts 19.41 kB (➖)
vec4h from typegpudata.ts 19.41 kB (➖)
vec4i from typegpudata.ts 19.41 kB (➖)
vec4u from typegpudata.ts 19.41 kB (➖)
workgroupBarrier from typegpustd.ts 15.80 kB (➖)
writeToArrayBuffer from typegpu.ts 50.89 kB (➖)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.95, 1.98, 4.64, 6.12, 7.33, 11.94, 22.38, 25.66]
  line [0.86, 1.99, 4.01, 6.85, 7.47, 11.62, 21.36, 23.20]
  line [0.93, 1.92, 4.07, 6.89, 8.19, 10.62, 22.78, 24.29]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.30, 0.55, 0.69, 0.89, 1.17, 1.28, 1.53, 1.69]
  line [0.35, 0.55, 0.71, 0.85, 1.10, 1.13, 1.42, 1.55]
  line [0.34, 0.55, 0.73, 0.88, 1.23, 1.29, 1.54, 1.62]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [1.00, 2.24, 4.38, 7.05, 13.22, 25.95, 56.37, 117.19]
  line [0.88, 2.06, 4.22, 6.35, 12.60, 26.00, 55.71, 111.86]
  line [0.87, 1.96, 4.06, 6.27, 12.69, 25.91, 58.87, 119.54]
Loading

observer.observe(canvas, { box: 'content-box' });
}

return () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about returning a { detach: () => {} } so its self-documenting?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then the rest of the code will read autoResizer.detach()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, changed it 🫡

Comment thread packages/typegpu/src/common/attachAutoResizer.ts Outdated
@iwoplaza iwoplaza force-pushed the feat/resize-common branch from 64f3189 to 4567fed Compare May 26, 2026 14:41
@iwoplaza iwoplaza force-pushed the feat/resize-common branch 8 times, most recently from df4e541 to 11345a6 Compare June 17, 2026 17:52
@iwoplaza

Copy link
Copy Markdown
Collaborator Author

@pullfrog Review this one please 🙏

@iwoplaza iwoplaza force-pushed the feat/resize-common branch from b7bbb8b to 11fccf5 Compare June 17, 2026 20:39

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes — adds common.attachAutoResizer, a web helper that adapts the canvas' internal resolution to match its physical pixel size using ResizeObserver, then migrates all docs examples and CLI templates to use it.

  • Add attachAutoResizer helper — new common/attachAutoResizer.ts exports attachAutoResizer() with AttachAutoResizerOptions (root, canvas, optional onResize callback) and returns an AutoResizer with a detach() cleanup method. Internally uses ResizeObserver with a device-pixel-content-box fallback and clamps dimensions to the GPU's maxTextureDimension2D.
  • Migrate ~45 docs examples — each example's index.ts now imports common from typegpu, calls common.attachAutoResizer(), and calls autoResizer.detach() in onCleanup(). Standalone fullScreenTriangle imports are consolidated to common.fullScreenTriangle. Example canvases in index.html gain class="w-full h-full" for CSS-driven sizing.
  • Remove useResizableCanvas — the example-view React hook and its ~80 lines of canvas DOM manipulation are deleted, simplifying the docs app.
  • Trim stackBlitzIndex.ts — the embedded canvas-resize script (~50 lines of ResizeObserver + DOM wrapping) is removed since examples now self-resize.
  • Update CLI templates — both template-vite-simple and template-vite-complex replace manual ResizeObserver setup with common.attachAutoResizer().

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@iwoplaza iwoplaza force-pushed the feat/resize-common branch from 11fccf5 to c59c2a7 Compare June 18, 2026 08:00
@iwoplaza iwoplaza marked this pull request as ready for review June 18, 2026 08:00

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes — adds common.attachAutoResizer, a ResizeObserver-based helper that adapts a canvas' internal resolution to its physical pixel size, with device-pixel-content-box / content-box fallback and maxTextureDimension2D clamping. Replaces duplicate resize logic across all examples, templates, the docs ExampleView component, and the StackBlitz wrapper.

  • New attachAutoResizer helper at packages/typegpu/src/common/attachAutoResizer.ts — observes a canvas, sets canvas.width/canvas.height with DPR awareness and device-limit clamping, returns a { detach } handle. Exported via packages/typegpu/src/common/index.ts under the common namespace.
  • Docs ExampleView.tsx cleanup — removes the useResizableCanvas hook and its DOM-scaffolding logic (~80 lines). Example canvases are now sized via inline Tailwind classes (w-full h-full) and each example manages its own attachAutoResizer lifecycle.
  • StackBlitz wrapper cleanup — removes the inline canvas resize loop (~50 lines) from stackBlitzIndex.ts. Examples in StackBlitz now resize via their own attachAutoResizer calls.
  • Example updates — every example index.html replaces bare <canvas> / data-fit-to-container with <canvas class="w-full h-full" /> (and object-contain where appropriate). Every example index.ts imports common from typegpu, switches fullScreenTrianglecommon.fullScreenTriangle, and calls attachAutoResizer with onResize (for animated examples) or without (for requestAnimationFrame loops). Cleanup hooks call autoResizer.detach() before root.destroy().
  • CLI template updatestemplate-vite-simple and template-vite-complex replace inline ResizeObserver code with common.attachAutoResizer, demonstrating the intended usage.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

export interface AttachAutoResizerOptions {
root: TgpuRoot;
canvas: HTMLCanvasElement;
onResize?: (() => void) | undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onResize parameter is declared as onResize?: (() => void) | undefined. The ? already makes the type (() => void) | undefined, so the explicit | undefined is redundant.

Technical details
# Redundant `| undefined` on optional property

## Affected sites
- `packages/typegpu/src/common/attachAutoResizer.ts:6` — type annotation includes explicit `| undefined` union

## Required outcome
- Use either `onResize?: () => void` or `onResize: (() => void) | undefined`. Both produce the same runtime and structural type.

## Suggested approach
Drop the `| undefined` — the `?` already handles it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true. In codebases with exactOptionalPropertyTypes, having | undefined has meaning. If you omit undefined you are explicitly saying { onResize: undefined } can't be sent in.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new common.attachAutoResizer helper in typegpu to keep a canvas’s internal pixel resolution in sync with its displayed size (including DPR handling), and migrates the CLI templates + docs examples to use it so resizing no longer depends on the docs/StackBlitz “environment” code.

Changes:

  • Added packages/typegpu/src/common/attachAutoResizer.ts and exported it from common.
  • Updated templates and a large set of docs examples to use common.attachAutoResizer() and detach it during cleanup.
  • Simplified docs/StackBlitz canvas-environment resizing logic by removing the previous “wrap/replace canvas + ResizeObserver” approach.

Reviewed changes

Copilot reviewed 147 out of 147 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
packages/typegpu/src/common/index.ts Exports the new auto-resizer helper from common.
packages/typegpu/src/common/attachAutoResizer.ts Implements attachAutoResizer using ResizeObserver.
packages/typegpu-cli/templates/template-vite-simple/src/main.ts Replaces inline ResizeObserver resizing with common.attachAutoResizer.
packages/typegpu-cli/templates/template-vite-complex/src/main.ts Uses common.attachAutoResizer and renames render loop function to frame.
apps/typegpu-docs/src/examples/threejs/varyings/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/test-reused-functions/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/test-mismatched-types/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/simple/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/compute-particles/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/compute-particles-snow/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/compute-geometry/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/compute-cloth/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/threejs/attractors/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/tests/uniformity/index.ts Uses attachAutoResizer and detaches on cleanup; redraws on resize.
apps/typegpu-docs/src/examples/tests/uniformity/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/tests/texture-test/index.ts Adds attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/tests/texture-test/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/tests/sdf-docs-examples/index.ts Adds attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/tests/sdf-docs-examples/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/tests/rc-docs-examples/index.ts Adds attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/tests/rc-docs-examples/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/tests/log-test/index.ts Imports common, adds attachAutoResizer, detaches on cleanup.
apps/typegpu-docs/src/examples/tests/log-test/index.html Updates canvas tag formatting.
apps/typegpu-docs/src/examples/simulation/wind-map/index.ts Uses attachAutoResizer with square aspect enforcement and redraw.
apps/typegpu-docs/src/examples/simulation/wind-map/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/stable-fluid/index.ts Adds attachAutoResizer, refactors render loop, updates pointer mapping for square canvas.
apps/typegpu-docs/src/examples/simulation/stable-fluid/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/slime-mold/index.ts Adds attachAutoResizer and refactors render call; detaches on cleanup.
apps/typegpu-docs/src/examples/simulation/slime-mold/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.ts Adds attachAutoResizer, refactors render call; detaches on cleanup.
apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/gravity/index.ts Replaces ResizeObserver with attachAutoResizer for depth texture recreation.
apps/typegpu-docs/src/examples/simulation/gravity/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/game-of-life/input.ts Adjusts input coordinate mapping for square aspect and uses std.saturate.
apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts Adds attachAutoResizer and refactors display draw into render().
apps/typegpu-docs/src/examples/simulation/game-of-life/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.ts Adds attachAutoResizer with square resizing and redraw.
apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.ts Adds attachAutoResizer with square resizing and redraw.
apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/confetti/index.ts Adds attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/simulation/confetti/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simulation/boids/index.ts Refactors to render() + uses attachAutoResizer for square resizing and redraw.
apps/typegpu-docs/src/examples/simulation/boids/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/vaporrave/index.ts Refactors draw to render() and uses attachAutoResizer.
apps/typegpu-docs/src/examples/simple/vaporrave/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/triangle/index.ts Imports common, uses attachAutoResizer, refactors constants; detaches on cleanup.
apps/typegpu-docs/src/examples/simple/triangle/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/stencil/index.ts Replaces ResizeObserver with attachAutoResizer (square + texture recreation).
apps/typegpu-docs/src/examples/simple/stencil/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/square/index.ts Uses attachAutoResizer to drive initial render + rerender on resize.
apps/typegpu-docs/src/examples/simple/square/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/ripple-cube/post-processing.ts Refactors post-processing to support resizing and exposes a user storage binding group.
apps/typegpu-docs/src/examples/simple/ripple-cube/index.ts Integrates resizable post-processing and uses attachAutoResizer to resize pipelines.
apps/typegpu-docs/src/examples/simple/ripple-cube/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/oklab/index.ts Adjusts pointer mapping + uses attachAutoResizer; detaches on cleanup.
apps/typegpu-docs/src/examples/simple/oklab/index.html Wraps canvas/probe markup; updates canvas classes.
apps/typegpu-docs/src/examples/simple/mesh-skinning/index.ts Replaces ResizeObserver with attachAutoResizer to recreate depth/MSAA textures.
apps/typegpu-docs/src/examples/simple/mesh-skinning/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/liquid-glass/index.ts Splits render/frame loop and uses attachAutoResizer for square resizing.
apps/typegpu-docs/src/examples/simple/liquid-glass/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/simple/gradient-tiles/index.ts Uses attachAutoResizer for square resizing and redraw.
apps/typegpu-docs/src/examples/simple/gradient-tiles/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/xor-dev-runner/index.ts Imports common, uses attachAutoResizer, detaches on cleanup.
apps/typegpu-docs/src/examples/rendering/xor-dev-runner/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/xor-dev-centrifuge-2/index.ts Imports common, uses attachAutoResizer, detaches on cleanup.
apps/typegpu-docs/src/examples/rendering/xor-dev-centrifuge-2/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/two-boxes/index.ts Replaces ResizeObserver with attachAutoResizer (square + texture recreation).
apps/typegpu-docs/src/examples/rendering/two-boxes/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/suika-sdf/index.ts Replaces ResizeObserver with attachAutoResizer; refactors into render().
apps/typegpu-docs/src/examples/rendering/suika-sdf/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/smoky-triangle/index.ts Refactors draw to render() and uses attachAutoResizer for square resizing.
apps/typegpu-docs/src/examples/rendering/smoky-triangle/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/simple-shadow/index.ts Replaces ResizeObserver with attachAutoResizer, refactors into render() + frame().
apps/typegpu-docs/src/examples/rendering/simple-shadow/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/render-bundles/index.ts Refactors to render() and uses attachAutoResizer to redraw on resize.
apps/typegpu-docs/src/examples/rendering/render-bundles/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/render-bundles-with/index.ts Refactors to render() and uses attachAutoResizer to redraw on resize.
apps/typegpu-docs/src/examples/rendering/render-bundles-with/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/ray-marching/index.ts Uses attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/rendering/ray-marching/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/radiance-cascades/index.ts Replaces ResizeObserver with attachAutoResizer + debounce; enforces square.
apps/typegpu-docs/src/examples/rendering/radiance-cascades/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/index.ts Uses attachAutoResizer and switches scene resolution to fixed 1024².
apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/drawInteraction.ts Updates pointer mapping for square aspect ratio.
apps/typegpu-docs/src/examples/rendering/pom/index.ts Replaces ResizeObserver with attachAutoResizer (depth recreate + redraw).
apps/typegpu-docs/src/examples/rendering/pom/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.ts Refactors render/frame loops and uses attachAutoResizer (square + texture recreate).
apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts Refactors to render() and uses attachAutoResizer (depth recreate + redraw).
apps/typegpu-docs/src/examples/rendering/phong-reflection/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/perlin-noise/index.ts Refactors draw to render() and uses attachAutoResizer for square resizing.
apps/typegpu-docs/src/examples/rendering/perlin-noise/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/os-awards/index.ts Replaces ResizeObserver with attachAutoResizer (depth recreate + redraw).
apps/typegpu-docs/src/examples/rendering/os-awards/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/jelly-switch/index.ts Refactors render loop and uses attachAutoResizer to drive handleResize().
apps/typegpu-docs/src/examples/rendering/jelly-switch/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/jelly-slider/index.ts Refactors render loop and uses attachAutoResizer to drive handleResize().
apps/typegpu-docs/src/examples/rendering/jelly-slider/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/function-visualizer/index.ts Replaces ResizeObserver with attachAutoResizer to recreate MSAA texture.
apps/typegpu-docs/src/examples/rendering/function-visualizer/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/disco/index.ts Splits render/frame and uses attachAutoResizer to redraw on resize.
apps/typegpu-docs/src/examples/rendering/disco/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.ts Replaces ResizeObserver with attachAutoResizer and redraws on resize.
apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/clouds/types.ts Adds aspectRatio to params struct.
apps/typegpu-docs/src/examples/rendering/clouds/index.ts Uses attachAutoResizer, adds aspect-ratio uniform and low-res rendering behavior.
apps/typegpu-docs/src/examples/rendering/clouds/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/caustics/index.ts Refactors draw to render() and uses attachAutoResizer for square resizing.
apps/typegpu-docs/src/examples/rendering/caustics/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/box-raytracing/index.ts Refactors draw to render() and uses attachAutoResizer for square resizing.
apps/typegpu-docs/src/examples/rendering/box-raytracing/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts Refactors to render() and uses attachAutoResizer (projection + depth recreation + redraw).
apps/typegpu-docs/src/examples/rendering/3d-fish/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/react/spinning-triangle/index.tsx Adjusts canvas sizing classes in React example.
apps/typegpu-docs/src/examples/react/shifting-gradient/index.tsx Adjusts canvas sizing classes in React example.
apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/index.ts Uses attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/index.html Converts hidden-video styling to Tailwind classes and updates canvas markup.
apps/typegpu-docs/src/examples/image-processing/image-tuning/index.ts Uses attachAutoResizer to render on resize; detaches on cleanup.
apps/typegpu-docs/src/examples/image-processing/image-tuning/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/image-processing/chroma-keying/index.ts Adds attachAutoResizer and refactors resize behavior via handleResize().
apps/typegpu-docs/src/examples/image-processing/chroma-keying/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.ts Adds attachAutoResizer and refactors resize behavior via handleResize().
apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/image-processing/blur/index.ts Uses attachAutoResizer for square resizing and redraw.
apps/typegpu-docs/src/examples/image-processing/blur/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts Refactors to handleResize() and uses attachAutoResizer; detaches on cleanup.
apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.ts Refactors to handleResize() and uses attachAutoResizer; detaches on cleanup.
apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/geometry/lines-combinations/index.ts Replaces ResizeObserver with attachAutoResizer (square + texture recreate + redraw).
apps/typegpu-docs/src/examples/geometry/lines-combinations/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/geometry/circles/index.ts Replaces ResizeObserver with attachAutoResizer (square + texture recreate + render).
apps/typegpu-docs/src/examples/geometry/circles/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts Adds attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.html Adjusts layout to flex and updates canvas markup/classes.
apps/typegpu-docs/src/examples/algorithms/jump-flood-voronoi/index.ts Replaces ResizeObserver with attachAutoResizer.
apps/typegpu-docs/src/examples/algorithms/jump-flood-voronoi/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/index.ts Replaces ResizeObserver with attachAutoResizer.
apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/algorithms/genetic-racing/index.ts Adds attachAutoResizer and detaches on cleanup.
apps/typegpu-docs/src/examples/algorithms/genetic-racing/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/examples/algorithms/bitonic-sort/index.ts Switches to common.fullScreenTriangle, adds attachAutoResizer, and detaches on cleanup.
apps/typegpu-docs/src/examples/algorithms/bitonic-sort/index.html Updates canvas markup/classes for new resizing approach.
apps/typegpu-docs/src/components/stackblitz/stackBlitzIndex.ts Removes the StackBlitz-side “resize canvases” environment logic.
apps/typegpu-docs/src/components/ExampleView.tsx Removes the docs-side “replace canvases + ResizeObserver” resizing hook; relies on examples.
Comments suppressed due to low confidence (2)

apps/typegpu-docs/src/examples/rendering/suika-sdf/index.html:5

  • <canvas ... /> is not a void element in HTML. The self-closing form will cause the following <link>/<style> tags to be parsed inside the canvas element when inserted via innerHTML. Use an explicit closing tag.
    apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.html:5
  • <canvas ... /> is not a void element in HTML. The following <video> tag will be parsed as a child of the canvas when this markup is injected via innerHTML. Use </canvas>.
<canvas class="w-full h-full object-contain" />
<video
  autoplay
  playsinline
  class="absolute top-0 left-0 w-px h-px opacity-0 pointer-events-none"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +35
const observer = new ResizeObserver((entries) => {
for (const entry of entries) {
if (!entry) {
return;
}
const width =
entry.devicePixelContentBoxSize?.[0]?.inlineSize ||
(entry.contentBoxSize[0]?.inlineSize ?? 0) * window.devicePixelRatio;
const height =
entry.devicePixelContentBoxSize?.[0]?.blockSize ||
(entry.contentBoxSize[0]?.blockSize ?? 0) * window.devicePixelRatio;
const canvas = entry.target as HTMLCanvasElement;
canvas.width = Math.max(1, Math.min(width, root.device.limits.maxTextureDimension2D));
canvas.height = Math.max(1, Math.min(height, root.device.limits.maxTextureDimension2D));

onResize?.();
}
});
Comment on lines +37 to +41
try {
observer.observe(canvas, { box: 'device-pixel-content-box' });
} catch {
observer.observe(canvas, { box: 'content-box' });
}
Comment on lines +115 to +120
const postProcessing = createPostProcessingPipelines(
root,
canvas.width * resolutionScale,
canvas.height * resolutionScale,
initialBloom,
);
Comment on lines +240 to +243
onResize() {
postProcessing.resize(canvas.width * resolutionScale, canvas.height * resolutionScale);
render();
},
Comment on lines +29 to +32
<div class="relative w-full h-full">
<canvas class="w-full h-full object-contain" />
<div id="css-probe"></div>
</div>
Comment on lines 1 to 4
<div class="loading">Model is loading...</div>
<canvas data-fit-to-container></canvas>
<canvas class="w-full h-full" />
<style>
.loading {
Comment on lines +1 to +7
<canvas class="w-full h-full object-contain" />
<!-- Keep the video "painted" so Safari continues decoding frames. -->
<video
autoplay
playsinline
class="absolute top-0 left-0 w-[1px] h-[1px] opacity-0 pointer-events-none"
/>
Comment on lines +144 to +145
let width = initialWidth;
let height = initialHeight;
Comment on lines +220 to +226
resize: (newWidth: number, newHeight: number) => {
if (newWidth !== width || newHeight !== height) {
width = newWidth;
height = newHeight;
resources = createResolutionDependantResources();
}
},
Comment on lines +146 to +155
function createResolutionDependantResources() {
const bloomWidth = Math.max(1, Math.floor(width / 2));
const bloomHeight = Math.max(1, Math.floor(height / 2));

const result = createProcessingTexture(root, width, height);
const bloom = createProcessingTexture(root, bloomWidth, bloomHeight);
const blurTemp = createProcessingTexture(root, bloomWidth, bloomHeight);
const history = createProcessingTexture(root, width, height);
const taaOutput = createProcessingTexture(root, width, height);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants