#575

macOS: main webview keeps its old size after a display or backing-scale change (only windowDidResize refits it)

OpenGeiserXopened 19d ago

On macOS, a window's main webview can end up smaller than the window. It keeps its old size after the window changes display, and the rest of the window shows the window's background around the page. Seen with Electrobun 2.0.1, titleBarStyle: "hiddenInset", on a Mac that moves windows between the built-in display and an external one with a different backing scale. The window had been open for hours, so I can't name the exact event that skipped the resize.

What the source shows (package/src/native/macos/nativeWrapper.mm at baf2746):

Inside the page everything looks normal: innerWidth and innerHeight are the old size and the document fits them. Only the native frame is wrong.

Suggested fix: in the window delegate, handle windowDidChangeScreen: and windowDidChangeBackingProperties: the same way windowDidResize: handles full-size views, by calling resize:contentView.bounds withMasksJSON:"" for each abstractView.fullSize. Another option is to give full-size webviews NSViewWidthSizable | NSViewHeightSizable so AppKit keeps them filling the content view whatever changes the window.

The workaround in our app: the page reports its viewport to the main process, and when it differs from the window by more than a pixel, the app calls setSize(width + 1, height) and then setSize(width, height). That goes through windowDidResize: twice and fits the webview again.

Activity

0

No activity yet.