Repository navigation
Conversation
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 1.28%) | ❔ Unknown |
|---|---|---|---|
| 0 | 353 | 2 | 1 |
import * as ... in PR vs import * as ... in target (did bundle size increase?):
| Test | tsdown |
|---|---|
| STATIC_common.ts | 57.05 kB ( |
| common_attachAutoResizer.ts | 722 B |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
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 [1.21, 2.36, 4.85, 7.92, 9.63, 14.75, 28.53, 31.21]
line [1.11, 2.31, 4.89, 7.26, 9.13, 15.07, 29.79, 32.38]
line [1.07, 2.23, 5.17, 6.95, 9.25, 13.79, 27.15, 30.34]
---
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.34, 0.63, 0.81, 0.96, 1.37, 1.39, 1.65, 1.92]
line [0.38, 0.59, 0.83, 0.96, 1.31, 1.35, 1.63, 1.82]
line [0.32, 0.57, 0.74, 0.89, 1.26, 1.33, 1.54, 1.72]
---
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 [0.94, 2.35, 4.78, 8.80, 16.16, 30.08, 64.92, 130.67]
line [0.93, 2.39, 4.65, 8.02, 14.82, 31.07, 63.85, 128.77]
line [1.00, 2.73, 4.46, 8.58, 14.17, 28.74, 62.32, 126.03]
|
64f3189 to
4567fed
Compare
df4e541 to
11345a6
Compare
|
@pullfrog Review this one please 🙏 |
b7bbb8b to
11fccf5
Compare
There was a problem hiding this comment.
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
attachAutoResizerhelper — newcommon/attachAutoResizer.tsexportsattachAutoResizer()withAttachAutoResizerOptions(root,canvas, optionalonResizecallback) and returns anAutoResizerwith adetach()cleanup method. Internally usesResizeObserverwith adevice-pixel-content-boxfallback and clamps dimensions to the GPU'smaxTextureDimension2D. - Migrate ~45 docs examples — each example's
index.tsnow importscommonfromtypegpu, callscommon.attachAutoResizer(), and callsautoResizer.detach()inonCleanup(). StandalonefullScreenTriangleimports are consolidated tocommon.fullScreenTriangle. Example canvases inindex.htmlgainclass="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 ofResizeObserver+ DOM wrapping) is removed since examples now self-resize. - Update CLI templates — both
template-vite-simpleandtemplate-vite-complexreplace manualResizeObserversetup withcommon.attachAutoResizer().
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
11fccf5 to
c59c2a7
Compare
There was a problem hiding this comment.
ℹ️ 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
attachAutoResizerhelper atpackages/typegpu/src/common/attachAutoResizer.ts— observes a canvas, setscanvas.width/canvas.heightwith DPR awareness and device-limit clamping, returns a{ detach }handle. Exported viapackages/typegpu/src/common/index.tsunder thecommonnamespace. - Docs
ExampleView.tsxcleanup — removes theuseResizableCanvashook 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 ownattachAutoResizerlifecycle. - StackBlitz wrapper cleanup — removes the inline canvas resize loop (~50 lines) from
stackBlitzIndex.ts. Examples in StackBlitz now resize via their ownattachAutoResizercalls. - Example updates — every example
index.htmlreplaces bare<canvas>/data-fit-to-containerwith<canvas class="w-full h-full" />(andobject-containwhere appropriate). Every exampleindex.tsimportscommonfromtypegpu, switchesfullScreenTriangle→common.fullScreenTriangle, and callsattachAutoResizerwithonResize(for animated examples) or without (for requestAnimationFrame loops). Cleanup hooks callautoResizer.detach()beforeroot.destroy(). - CLI template updates —
template-vite-simpleandtemplate-vite-complexreplace inlineResizeObservercode withcommon.attachAutoResizer, demonstrating the intended usage.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
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.tsand exported it fromcommon. - 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 viainnerHTML. 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 viainnerHTML. 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.
aleksanderkatan
left a comment
There was a problem hiding this comment.
Here are some things I noticed:
Many examples (mostly orbit camera ones, but not all of those) throw when resizing the page to be so small that only example list is displayed.
http://localhost:4321/TypeGPU/examples#example=rendering--os-awards a FiniteMathAssumption error is thrown (before, it had wgsl errors), it seems that it works regardless
http://localhost:4321/TypeGPU/examples#example=simulation--gravity -||-
http://localhost:4321/TypeGPU/examples#example=rendering--pom -||-
http://localhost:4321/TypeGPU/examples#example=rendering--xor-dev-runner -||-
http://localhost:4321/TypeGPU/examples#example=rendering--function-visualizer -||-
http://localhost:4321/TypeGPU/examples#example=rendering--phong-reflection -||-
http://localhost:4321/TypeGPU/examples#example=rendering--render-bundles -||-
http://localhost:4321/TypeGPU/examples#example=rendering--render-bundles-with -||-
http://localhost:4321/TypeGPU/examples#example=simple--ripple-cube -||-, also has many WGSL warnings
http://localhost:4321/TypeGPU/examples#example=simple--mesh-skinning crashes
http://localhost:4321/TypeGPU/examples#example=algorithms--jump-flood-distance started flashing black when resizing
| const resizeObserver = new ResizeObserver(() => { | ||
| canvasRatioUniform.write(canvas.width / canvas.height); | ||
| redraw(); | ||
| const autoResizer = common.attachAutoResizer({ |
There was a problem hiding this comment.
Were three examples intentionally excluded from this change?
There was a problem hiding this comment.
Yes, Three.js handles resizing on its own
c59c2a7 to
2d2827f
Compare
There was a problem hiding this comment.
Important
One example can still create 0-sized textures on collapse. Otherwise the attachAutoResizer rewrite and example migrations look good.
Reviewed changes — incremental delta since the prior pullfrog review (the branch was rebased onto main, so this covers the net changes over c59c2a7..2d2827f).
- Hardened
attachAutoResizer— physical size now resolves throughdevicePixelContentBoxSize→contentBoxSize(array or legacy single object)* dpr→contentRect * dpr, dimensions are rounded and clamped to[1, maxSize], device limits are read behind atry/catchfor non-WebGPU roots, andobserve()gained a bare-observefinal fallback. - Example test harness —
commonMocks.tsnow stubs a globalResizeObserverthat emits an initial256x256entry, so the migrated examples' resize path runs under test. - Canvas markup fix — all example
index.htmlfiles converted self-closing<canvas ... />to explicit<canvas ...></canvas>, which otherwise nested following nodes inside the canvas when injected viainnerHTML. - Newly-added examples migrated —
texture-gl,triangle-gl,triplanar-mapping,trippy-raymarching,global-illumination, andmonocular-light-injectionnow usecommon.attachAutoResizer; several examples were split intoscene.tsmodules exposingonResize/onCleanup. - Prior review feedback — the redundant
| undefinedconcern was discussed; the branch retains it intentionally (exact optional properties).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental delta since the prior pullfrog review (19645d6..8a0c65e), commit 8a0c65e ("Address review comments").
- Clamped
jump-flood-distance'supdateDimensions()withMath.max(1, ...), so a collapsed canvas yields a 1x1 render target instead of 0-sized textures. - Converted
tests/triangle-targets/index.html's self-closing<canvas ... />to an explicit<canvas ...></canvas>.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
8a0c65e to
2aaecce
Compare
2aaecce to
2d47878
Compare
There was a problem hiding this comment.
That's because common.attachAutoResizer isn't published yet, and Stackblitz uses the pinned published version of typegpu
|
|
||
| // Adjusting the resolution when the physical size of the canvas changes, | ||
| // and re-rendering the content. | ||
| common.attachAutoResizer({ |
There was a problem hiding this comment.
Shouldn't we to pin higher TypeGPU in package.json?
There was a problem hiding this comment.
Good catch, this should now happen automatically 🫡
#3298
| </div> | ||
|
|
||
| <canvas></canvas> | ||
| <canvas class="w-full h-full object-contain"></canvas> |
There was a problem hiding this comment.
ℹ️ No critical issues — one missed letterbox fix inline.
Reviewed changes — incremental delta since the prior pullfrog review (2d47878e5..79fd07ec3), commit 79fd07ec3 ("Fix pointer mapping in letterboxed examples").
- Corrected pointer mapping into the
object-containsquare —liquid-glass(updatePosition) andradiance-cascades' drag controller (canvasToUV) now mapclientX/clientYinto the centered drawn square viaMath.min(rect.width, rect.height)plus the(rect.width - size) / 2center offset, instead of the full element box. fluid-with-atomicscell mapping rewritten — theoffsetX * devicePixelRatiohelper (pointerCellFromCanvasOffset) is replaced bypointerCellFromClient, which maps into the drawn square and is now shared by both mouse and touch handlers.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental delta since the prior pullfrog review (79fd07ec3..4853241), commit 4853241e5 ("Fix pointer mapping in letterboxed jelly-slider example").
- Fixed the missed letterbox mapping in
jelly-slider—EventHandler.updateTargetMouseX(events.ts) now mapsclientXinto the centered drawn square viaMath.min(rect.width, rect.height)and the(rect.width - size) / 2offset, matchingliquid-glass,radiance-cascades, andfluid-with-atomics, instead of normalizing over the full element box. Resolves the prior review's single inline thread.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
92e9ee3 to
a87aad1
Compare
There was a problem hiding this comment.
✅ No new issues found.
( ◦°^°◦) Ahoy, mateys! I re-reviewed the lone new commit on this here PR — a cosmetic move of the camera preview from starboard to port in two camera examples — and found nary a bug. All prior pullfrog threads be resolved, so I hoist the green flag.
Reviewed changes — incremental delta since the prior pullfrog review (4853241e5..a87aad1a3), commit a87aad1a3 ("Move camera preview to bottom-left in camera examples"). The branch was rebased onto newer main, so the range-diff also carries base-branch noise (the @typegpu/sort → @typegpu/algorithm rename); the only PR-authored change is this commit.
- Repositioned the camera preview —
image-processing/ascii-filter/index.htmlandimage-processing/camera-thresholding/index.htmlnow anchor the<video>preview atleft: 10pxinstead ofright: 10px, keeping it clear of the example controls. This is a deliberate response to the human reviewer's open "camera position changed" thread.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The appjs-venue example now recreates its render targets from onResize with hard-coded mipLevelCount: 2, which is invalid once the canvas collapses to the helper's 1x1 minimum.
Reviewed changes — incremental delta since the prior pullfrog review (a87aad1a3..0a967c1), commit 0a967c1 ("Use common.attachAutoResizer in App.js Venue example, update brush size on resize in jump-flood-distance").
- Migrated
appjs-venuetocommon.attachAutoResizer— canvas markup switched fromdata-fit-to-containertow-full h-full; the draw body was split out offrame()intorender(); render-target recreation moved from the per-frame size check intoonResize; andautoResizer.detach()was added toonCleanup(). - Recomputed brush size on resize in
jump-flood-distance—updateBrushSize()is now called from theonResizecallback, so the brush radius follows the resized texture dimensions instead of staying at its initial value.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
- Make attachAutoResizer more robust (rounding, contentBoxSize shapes, observe() without options, roots without a WebGPU device) - Use explicit closing tags for <canvas> and <video> - Keep the 1:1 aspect ratio in bitonic-sort and sdf-docs-examples - Remove the resizer from log-test - Use integer sizes and destroy stale textures in ripple-cube
- Forward onResize from the Jelly Slider landing example, and make it required for landing examples - Only recreate blur textures in background-segmentation when the video frame size changes
Map pointer coordinates into the centered square drawn by object-contain in liquid-glass, radiance-cascades and fluid-with-atomics.
0a967c1 to
3d517f9
Compare
There was a problem hiding this comment.
ℹ️ No new issues in this delta.
( ◦°^°◦) Arr, I re-checked the fresh commits on this here PR — a tidy tonemapping migration and a swizzle snapshot regen — and spied nary a new bug, so this be informational rather than an approval, since the old appjs-venue thread still be open.
Reviewed changes — incremental delta since the prior pullfrog review (0a967c1..3d517f9), commits 3d517f9a6 and 5704332a6. The branch was rebased again onto newer main, so the range-diff also carries base-branch noise; these are the only PR-authored changes.
- Migrated
tonemappingtocommon.attachAutoResizer— the example'sindex.htmlcanvas switched fromdata-fit-to-containertow-full h-full, andindex.tsnow callscommon.attachAutoResizer({ root, canvas })and detaches it inonCleanup. The existingrequestAnimationFrameloop already rewritesresolutionUniformfromcanvas.width/canvas.heightevery frame, so noonResizecallback is needed. - Regenerated example-test snapshots —
3d-fish.test.tsandslime-mold-3d.test.tssnapshots now emit swizzle access (repulsion.x,gpuSeed.y) instead of integer indexing (repulsion[0i],gpuSeed[1i]), matching the base's WGSL/JS vector swizzle-assignment codegen after the rebase. Test-only.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
3d517f9 to
2cfcb82
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental delta since the prior pullfrog review (3d517f9..2cfcb82). The branch was rebased again, so the raw commit range carries noise; the range-diff nets to a single authored change — the fix for the prior review's appjs-venue finding. The tonemapping migration and swizzle snapshot regen are byte-identical across the rebase and were already reviewed.
- Guarded
appjs-venuerender-target recreation at the 1x1 minimum —render()andonResize()now bail via the newisCanvasTooSmall()(canvas.width < 2 || canvas.height < 2), so the targets created withmipLevelCount: 2are never constructed while the canvas is collapsed below the two-mip-level size, and thegenerateMipmaps(0, 2)path is skipped. This resolves the prior IMPORTANT thread onappjs-venue; the thread is now resolved.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏




This PR adds a new common helper called
attachAutoResizerwhich 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.