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):
- The main WKWebView gets
autoresizingMask = NSViewNotSizableanddrawsBackground = NO, so AppKit never resizes it, and uncovered window area shows through. https://github.com/blackboardsh/electrobun/blob/baf2746197a81686a978bf6f747f3cdda8fcb999/package/src/native/macos/nativeWrapper.mm#L3024-L3029 - The only place a full-size webview gets fitted to the window again is the window delegate's
windowDidResize:, which sets it tocontentView.bounds. https://github.com/blackboardsh/electrobun/blob/baf2746197a81686a978bf6f747f3cdda8fcb999/package/src/native/macos/nativeWrapper.mm#L8034-L8045 - The delegate has no
windowDidChangeScreen:orwindowDidChangeBackingProperties:. A screen or scale change that does not go throughwindowDidResize:therefore leaves the webview at its old frame.
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
0No activity yet.