Bug 1749745 - Initialize AndroidCompositorWidget with initial size. r=aosmond,agi a=RyanVM
authorJamie Nicol <jnicol@mozilla.com>
Wed, 12 Jan 2022 16:43:51 +0000
changeset 673749 8edd0d6b641be9a38a52f26c135e25ea7473bc9c
parent 673748 032a50096f1eec996ff70e3902a430e95b3a0fbf
child 673750 fed6019996e4e6a4ab1e8c00d77c94465154c8a6
push id16231
push userryanvm@gmail.com
push dateThu, 13 Jan 2022 14:40:24 +0000
treeherdermozilla-beta@fed6019996e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond, agi, RyanVM
bugs1749745, 1747116
milestone97.0
Bug 1749745 - Initialize AndroidCompositorWidget with initial size. r=aosmond,agi a=RyanVM Since bug 1747116 landed, if the compositor is reinitialized whilst the Android Surface is invalid, we avoid crashing when querying the window size and instead keep the compositor in a paused state. However, in this case we will believe the widget size is 0x0 until the compositor is eventually resumed. If webrender receives a display list during this time, it will set an empty view rect. This means when the compositor is subsequently resumed webrender believes it has nothing to render, and we get stuck in a state where nothing is ever rendered to the screen. This patch initializes the AndroidCompositorWidget with an initial size, which avoids the problem. Differential Revision: https://phabricator.services.mozilla.com/D135711
widget/android/AndroidCompositorWidget.cpp
widget/android/PlatformWidgetTypes.ipdlh
widget/android/nsWindow.cpp
--- a/widget/android/AndroidCompositorWidget.cpp
+++ b/widget/android/AndroidCompositorWidget.cpp
@@ -15,17 +15,17 @@ namespace widget {
 
 AndroidCompositorWidget::AndroidCompositorWidget(
     const AndroidCompositorWidgetInitData& aInitData,
     const layers::CompositorOptions& aOptions)
     : CompositorWidget(aOptions),
       mWidgetId(aInitData.widgetId()),
       mNativeWindow(nullptr),
       mFormat(WINDOW_FORMAT_RGBA_8888),
-      mClientSize(0, 0) {}
+      mClientSize(aInitData.clientSize()) {}
 
 AndroidCompositorWidget::~AndroidCompositorWidget() {
   if (mNativeWindow) {
     ANativeWindow_release(mNativeWindow);
   }
 }
 
 already_AddRefed<gfx::DrawTarget>
--- a/widget/android/PlatformWidgetTypes.ipdlh
+++ b/widget/android/PlatformWidgetTypes.ipdlh
@@ -9,16 +9,17 @@ include HeadlessWidgetTypes;
 using mozilla::LayoutDeviceIntSize from "Units.h";
 
 namespace mozilla {
 namespace widget {
 
 struct AndroidCompositorWidgetInitData
 {
   int32_t widgetId;
+  LayoutDeviceIntSize clientSize;
 };
 
 union CompositorWidgetInitData
 {
   AndroidCompositorWidgetInitData;
   HeadlessCompositorWidgetInitData;
 };
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -2580,17 +2580,18 @@ void nsWindow::SetCompositorWidgetDelega
                "non-PlatformCompositorWidgetDelegate");
   } else {
     mCompositorWidgetDelegate = nullptr;
   }
 }
 
 void nsWindow::GetCompositorWidgetInitData(
     mozilla::widget::CompositorWidgetInitData* aInitData) {
-  *aInitData = mozilla::widget::AndroidCompositorWidgetInitData(mWidgetId);
+  *aInitData = mozilla::widget::AndroidCompositorWidgetInitData(
+      mWidgetId, GetClientSize());
 }
 
 bool nsWindow::WidgetPaintsBackground() {
   return StaticPrefs::android_widget_paints_background();
 }
 
 bool nsWindow::NeedsPaint() {
   auto lvs(mLayerViewSupport.Access());