tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.95k stars 2.46k forks source link

Сhoppy animation when the canvas is stretched across the window, and smooth when the canvas is at a fixed size #9373

Open 8Observer8 opened 5 months ago

8Observer8 commented 5 months ago

Hello,

I created a simple example of keyframe animation using the requestAnimationFrame function. It works perfectly smooth in the browser: https://plnkr.co/edit/Auqa82LUfLttx5DO?preview

But when I build my example to EXE for Window 10 it is very choppy: simple-key-frame-animation-tauri-exe.zip

The animation becomes smooth if I make the canvas fixed rather than stretching it across the entire window:

    <canvas id="renderCanvas" width="380" height="380">
        Your browser does not support HTML5 canvas element.
    </canvas>

But when I resize the window with the mouse, the animation stops being smooth and becomes jerky. You can reproduce a problem. Download this folder: src.zip, copy the folder content to the "src" folder of "tauri-app", run it: npm run tauri dev. You will see a smooth animation. Try to change size of the window and after it the animation will be jerky.

image

Originally posted by @8Observer8 in https://github.com/tauri-apps/tauri/discussions/9364

8Observer8 commented 5 months ago

The same behavior with Three.js movement animation: https://plnkr.co/edit/L4ImaJsseDf799Ky?preview Сhoppy animation when the canvas is stretched across the window, and smooth when the canvas is at a fixed size.

Run and compare the next examples:

index.html ```html Armchair ```
index.html ```html Armchair ```