Bug 1769900 - Add more logs of window size sanity check around nsWindow r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D146658
This commit is contained in:
sotaro
2022-05-18 15:15:41 +00:00
parent 1280cfc4b5
commit a6fbfbb8da
4 changed files with 45 additions and 2 deletions

View File

@@ -78,8 +78,7 @@ bool WebRenderLayerManager::Initialize(
LayoutDeviceIntSize size = mWidget->GetClientSize(); LayoutDeviceIntSize size = mWidget->GetClientSize();
// Check widget size // Check widget size
if (size.width < 0 || size.width > wr::MAX_RENDER_TASK_SIZE || if (!wr::WindowSizeSanityCheck(size.width, size.height)) {
size.height < 0 || size.height > wr::MAX_RENDER_TASK_SIZE) {
gfxCriticalNoteOnce << "Widget size is not valid " << size gfxCriticalNoteOnce << "Widget size is not valid " << size
<< " isParent: " << XRE_IsParentProcess(); << " isParent: " << XRE_IsParentProcess();
} }

View File

@@ -61,6 +61,14 @@ struct ExternalImageKeyPair {
/* Generate a brand new window id and return it. */ /* Generate a brand new window id and return it. */
WindowId NewWindowId(); WindowId NewWindowId();
inline bool WindowSizeSanityCheck(int32_t aWidth, int32_t aHeight) {
if (aWidth < 0 || aWidth > wr::MAX_RENDER_TASK_SIZE || aHeight < 0 ||
aHeight > wr::MAX_RENDER_TASK_SIZE) {
return false;
}
return true;
}
inline DebugFlags NewDebugFlags(uint32_t aFlags) { return {aFlags}; } inline DebugFlags NewDebugFlags(uint32_t aFlags) { return {aFlags}; }
inline Maybe<wr::ImageFormat> SurfaceFormatToImageFormat( inline Maybe<wr::ImageFormat> SurfaceFormatToImageFormat(

View File

@@ -951,6 +951,12 @@ void nsWindow::ResizeInt(int aX, int aY, int aWidth, int aHeight, bool aMove) {
// interpreted as frame bounds, but NativeResize treats these as window // interpreted as frame bounds, but NativeResize treats these as window
// bounds (Bug 581866). // bounds (Bug 581866).
mBounds.SizeTo(aWidth, aHeight); mBounds.SizeTo(aWidth, aHeight);
// Check mBounds size
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(mBounds.width, mBounds.height)) {
gfxCriticalNoteOnce << "Invalid mBounds in ResizeInt " << mBounds
<< " size state " << mSizeState;
}
// We set correct mBounds in advance here. This can be invalided by state // We set correct mBounds in advance here. This can be invalided by state
// event. // event.
@@ -1875,6 +1881,13 @@ void nsWindow::NativeMoveResizeWaylandPopupCallback(
if (resizedByLayout) { if (resizedByLayout) {
mBounds.width = mNewBoundsAfterMoveToRect.width; mBounds.width = mNewBoundsAfterMoveToRect.width;
mBounds.height = mNewBoundsAfterMoveToRect.height; mBounds.height = mNewBoundsAfterMoveToRect.height;
// Check mBounds size
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(mBounds.width, mBounds.height)) {
gfxCriticalNoteOnce
<< "Invalid mNewBoundsAfterMoveToRect in PopupCallback " << mBounds
<< " size state " << mSizeState;
}
} }
mNewBoundsAfterMoveToRect = LayoutDeviceIntRect(0, 0, 0, 0); mNewBoundsAfterMoveToRect = LayoutDeviceIntRect(0, 0, 0, 0);
@@ -1934,6 +1947,12 @@ void nsWindow::NativeMoveResizeWaylandPopupCallback(
mMoveToRectPopupSize.height); mMoveToRectPopupSize.height);
} }
mBounds = newBounds; mBounds = newBounds;
// Check mBounds size
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(mBounds.width, mBounds.height)) {
gfxCriticalNoteOnce << "Invalid mBounds in PopupCallback " << mBounds
<< " size state " << mSizeState;
}
WaylandPopupPropagateChangesToLayout(needsPositionUpdate, needsSizeUpdate); WaylandPopupPropagateChangesToLayout(needsPositionUpdate, needsSizeUpdate);
} }
@@ -3925,6 +3944,12 @@ void nsWindow::OnSizeAllocate(GtkAllocation* aAllocation) {
} }
mBounds.SizeTo(size); mBounds.SizeTo(size);
// Check mBounds size
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(mBounds.width, mBounds.height)) {
gfxCriticalNoteOnce << "Invalid mBounds in OnSizeAllocate " << mBounds
<< " size state " << mSizeState;
}
// Notify the GtkCompositorWidget of a ClientSizeChange // Notify the GtkCompositorWidget of a ClientSizeChange
if (mCompositorWidgetDelegate) { if (mCompositorWidgetDelegate) {
@@ -4888,6 +4913,11 @@ void nsWindow::OnScaleChanged() {
LayoutDeviceIntSize size = GdkRectToDevicePixels(allocation).Size(); LayoutDeviceIntSize size = GdkRectToDevicePixels(allocation).Size();
mBoundsAreValid = true; mBoundsAreValid = true;
mBounds.SizeTo(size); mBounds.SizeTo(size);
// Check mBounds size
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(mBounds.width, mBounds.height)) {
gfxCriticalNoteOnce << "Invalid mBounds in OnScaleChanged " << mBounds;
}
if (mWidgetListener) { if (mWidgetListener) {
if (PresShell* presShell = mWidgetListener->GetPresShell()) { if (PresShell* presShell = mWidgetListener->GetPresShell()) {

View File

@@ -2595,6 +2595,12 @@ LayoutDeviceIntRect nsWindow::GetBounds() {
} }
} }
rect.MoveTo(r.left, r.top); rect.MoveTo(r.left, r.top);
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(rect.width, rect.height)) {
gfxCriticalNoteOnce << "Invalid size" << rect << " size mode "
<< mFrameState->GetSizeMode();
}
return rect; return rect;
} }