Bug 1726807 - Avoid crashes caused by floating point errors, r=gfx-reviewers,lsalzman
authorRobert Mader <robert.mader@posteo.de>
Sun, 22 Aug 2021 08:44:48 +0000
changeset 589518 23f3a0afb545acb23a5927696df94085ea74fcfe
parent 589517 2e74756a7120483870e36b4ca7be3a8d0f2c6f7b
child 589519 7ce99e7626d2b9537cfe90dd20c7cea27d9fb154
push id148402
push userrobert.mader@posteo.de
push dateSun, 22 Aug 2021 08:47:12 +0000
treeherderautoland@23f3a0afb545 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfx-reviewers, lsalzman
bugs1726807
milestone93.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1726807 - Avoid crashes caused by floating point errors, r=gfx-reviewers,lsalzman We always expect integer values here, even with fractional scaling, and if floating point errors cause `bufferClip.x` or `bufferClip.y` to fall slightly below `0`, this will cause a protocol error. We can savely avoid this by simply rounding the rect. Differential Revision: https://phabricator.services.mozilla.com/D123289
gfx/layers/NativeLayerWayland.cpp
--- a/gfx/layers/NativeLayerWayland.cpp
+++ b/gfx/layers/NativeLayerWayland.cpp
@@ -195,16 +195,18 @@ bool NativeLayerRootWayland::CommitToScr
       layer->SetSubsurfacePosition(floor(surfaceRectClipped.x / bufferScale),
                                    floor(surfaceRectClipped.y / bufferScale));
       layer->SetViewportDestinationSize(
           ceil(surfaceRectClipped.width / bufferScale),
           ceil(surfaceRectClipped.height / bufferScale));
 
       auto transform2DInversed = transform2D.Inverse();
       Rect bufferClip = transform2DInversed.TransformBounds(surfaceRectClipped);
+      // avoid floating point issues - we always expect integer values here
+      bufferClip.Round();
       layer->SetViewportSourceRect(bufferClip);
 
       layer->Commit();
     } else {
       layer->Unmap();
     }
   }