From a07f134cf6f826392bfa999ccfa369d231af9263 Mon Sep 17 00:00:00 2001 From: Tariq Bashir Date: Mon, 6 Jul 2026 14:32:54 +0100 Subject: [PATCH] fix: stop GetMaximumSize returning INT_MAX if max size not set OS-21471 Carson test electron-tests is failing on series 6 devices most of the time and sometimes on series 5 devices in SkBitmap::allocPixels. The crash is because the height is set to 8388608, which would require ~12 GB of RAM. The error is caused by a fix added for windows to NativeFrameView::GetMaximumSize(). The code returns gfx::Size(INT_MAX, INT_MAX) as a sentinel when no maximum window size is set. INT_MAX propagates through SizeWithDecorations() and AdjustBoundsToConstraintsDIP() arithmetic, overflowing signed 32-bit integers to ~0x800000 (~8388608). Under a Wayland configure race (compositor sends width=N, height=0 while client is mid-layout), the Views framework briefly applies this overflowed value as the actual window bounds. The HWNDMessageHandler::SetAspectRatio comment justifying INT_MAX was Windows-only and does not apply to Ozone Wayland builds. --- shell/browser/ui/views/native_frame_view.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/browser/ui/views/native_frame_view.cc b/shell/browser/ui/views/native_frame_view.cc index 5510228be13b4..b4ae91605e20d 100644 --- a/shell/browser/ui/views/native_frame_view.cc +++ b/shell/browser/ui/views/native_frame_view.cc @@ -18,9 +18,13 @@ gfx::Size NativeFrameView::GetMinimumSize() const { gfx::Size NativeFrameView::GetMaximumSize() const { gfx::Size size = window_->GetMaximumSize(); +#if BUILDFLAG(IS_LINUX) + return size; +#else // Electron public APIs returns (0, 0) when maximum size is not set, but it // would break internal window APIs like HWNDMessageHandler::SetAspectRatio. return size.IsEmpty() ? gfx::Size(INT_MAX, INT_MAX) : size; +#endif } BEGIN_METADATA(NativeFrameView)