tauri-apps / tauri

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

[bug] Manual WebView resizing does not work correctly #10053

Open kanatapple opened 2 weeks ago

kanatapple commented 2 weeks ago

Describe the bug

Manually resizing the WebView(set_size) results in incorrect positioning of the WebView. However, if the WebView coordinates are set to (0., 0.), it works correctly.

https://youtu.be/02gJWTb1Hjg

Reproduction

https://github.com/kanatapple/tauri-manual-resize

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 125.0.2535.92
    ✔ MSVC:
        - Visual Studio Professional 2017
        - Visual Studio Professional 2019
    ✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
    ✔ cargo: 1.77.2 (e52e36006 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.11.0
    - yarn: 1.22.11
    - npm: 10.2.4

[-] Packages
    - tauri [RUST]: 2.0.0-beta.22
    - tauri-build [RUST]: 2.0.0-beta.17
    - wry [RUST]: 0.40.1
    - tao [RUST]: 0.28.1
    - tauri-cli [RUST]: 1.2.3
    - @tauri-apps/api [NPM]: 2.0.0-beta.13
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - bundler: Vite

Stack trace

No response

Additional context

No response

kanatapple commented 1 week ago

If the initial position is (1, 1) and scale_factor is 1.5 (150%), the position becomes (2, 2) in set_bounds . In bounds.position.to_physical it becomes (1.5, 1.5), but it is cast to (2, 2).

After that, the position seems to increase from (2, 2) -> (3, 3), (3, 3) -> (5, 5), and so on.

kanatapple commented 1 week ago

Now that I know the cause, I'll send a Pull Request later.