tauri-apps / tauri

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

[bug] The size of the webview does not change when the tauri app window changes size on MacOs #6927

Open mattwhatsup opened 1 year ago

mattwhatsup commented 1 year ago

Describe the bug

When I use window management software like Magnet app on MacOs, the size of the webview does not change when I change the window size. It seems that this only happens on the height, and there is no problem with the width. How can I solve it?

Also, I think Safari kernel is really hard to use, Tauri should give developers an option whether to use Chromium as webview, otherwise adaptation is also painful, developers may not care about increment of a dozen megabytes of software package at all.

Reproduction

To demonstrate the issue:

import { appWindow } from '@tauri-apps/api/window'

appWindow.onResized(async () => {
  let size = await appWindow.innerSize()
  console.log('app innerSize', { width: size.width, height: size.height })
})

window.onresize = () => {
  console.log('html innerSize', {
    width: window.innerWidth,
    height: window.innerHeight,
  })
}

When reisze the window by pulling window's frame, it works properly. Because the retina resolution, app's innerHeight - html's innerHeight * 2 always equal 44(title bar height)

[Log] @@@app innerSize – {width: 640, height: 2012} (main.tsx, line 15)
[Log] ***html innerSize – {width: 320, height: 984} (main.tsx, line 21)

But when change the size by magnet, or max the window by drag the window to top of desktop's menubar, the webview's size is incorrect.

[Log] ***html innerSize – {width: 1160, height: 816} (main.tsx, line 21)
[Log] @@@app innerSize – {width: 2320, height: 2054} (main.tsx, line 15)

Also notice the order of the logs printed is not correct .

Expected behavior

No response

Platform and versions

My tauri version is 1.3.0, @tauri-apps/cli version is 1.3.1, safari version is 13.1.3.

Stack trace

No response

Additional context

No response

mattwhatsup commented 1 year ago

New discovery:

To reproduce it, do not need Magnet App, as if you drag the bottom frame fast enough, it will occur.

dizys commented 1 year ago

To add to this, on macOS when double clicking the data-tauri-drag-region area to resize the window, the Webview will also not change its size during transition.