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();
// Check widget size
if (size.width < 0 || size.width > wr::MAX_RENDER_TASK_SIZE ||
size.height < 0 || size.height > wr::MAX_RENDER_TASK_SIZE) {
if (!wr::WindowSizeSanityCheck(size.width, size.height)) {
gfxCriticalNoteOnce << "Widget size is not valid " << size
<< " isParent: " << XRE_IsParentProcess();
}

View File

@@ -61,6 +61,14 @@ struct ExternalImageKeyPair {
/* Generate a brand new window id and return it. */
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 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
// bounds (Bug 581866).
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
// event.
@@ -1875,6 +1881,13 @@ void nsWindow::NativeMoveResizeWaylandPopupCallback(
if (resizedByLayout) {
mBounds.width = mNewBoundsAfterMoveToRect.width;
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);
@@ -1934,6 +1947,12 @@ void nsWindow::NativeMoveResizeWaylandPopupCallback(
mMoveToRectPopupSize.height);
}
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);
}
@@ -3925,6 +3944,12 @@ void nsWindow::OnSizeAllocate(GtkAllocation* aAllocation) {
}
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
if (mCompositorWidgetDelegate) {
@@ -4888,6 +4913,11 @@ void nsWindow::OnScaleChanged() {
LayoutDeviceIntSize size = GdkRectToDevicePixels(allocation).Size();
mBoundsAreValid = true;
mBounds.SizeTo(size);
// Check mBounds size
if (mCompositorSession &&
!wr::WindowSizeSanityCheck(mBounds.width, mBounds.height)) {
gfxCriticalNoteOnce << "Invalid mBounds in OnScaleChanged " << mBounds;
}
if (mWidgetListener) {
if (PresShell* presShell = mWidgetListener->GetPresShell()) {

View File

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