[bug] Manual WebView resizing does not work correctly
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
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.
Now that I know the cause, I'll send a Pull Request later.
I have a similar issue with my app. Whatever values I use, my Webview fills the bottom half of the app window.
I reported this and @FabianLars responded that it might be related to this issue.
So I cloned the repo from the OP. In that case the Webview fills the whole app Window whatever I do with the commented out code.
No matter what I do I don't seem able to affect the position / size / behaviour of the Webview in the OP example or my app. This fits with my not understanding how the multiwebview example is achieving it's layout. I don't see how that can divide the vertical space equally between (four I think) Webviews, nor how it results in them taking up the full width.
A good place to start for me would be for the multiwebview example to be explained (and fixed first if indeed it is buggy, which seems to be the case).
[✔] Environment
- OS: Ubuntu 24.4.0 X64
✔ webkit2gtk-4.1: 2.44.0
✔ rsvg2: 2.58.0
✔ rustc: 1.79.0 (129f3b996 2024-06-10)
✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
- node: 22.1.0
- yarn: 1.22.22
- npm: 10.7.0
[-] 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]: 2.0.0-beta.20
- @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
I have a similar issue. Updating webview size using set_size causes cumulative positioning on Windows devices where it works perfect on Mac devices. Following here..
@happybeing @hattapoglu wry is fixed, so this issue should be fixed soon(Not sure if it's the same cause... 😅 )
Yeh, thanks. I suspect not based on the symptoms and the strangeness I see in the example - how does that work? I shall take a another look before long.