In bug 1747116 we were seeing crashes caused by the compositor being reinitialized while the android Surface is invalid.
D135117 attempted to prevent this situation occurring. It was uplifted to 96, but doesn't seem to have reduced crash numbers.
D135118 guarded against the crash if we find ourselves in this situation, by simply not resuming the compositor if we detect the surface. This does indeed fix the crash, but I believe may cause nothing to be rendered after the user has resumed the compositor properly. (Until the user subsequently resizes the window, eg opens the keyboard).
The patch makes it so that instead of calling
ANativeWindow_getWidth/Height() for every
AndroidCompositorWidget::GetClientSize() call, we instead only do so in
AndroidCompositorWidget::OnResumeComposition() and cache the result. When this gets called with an invalid Surface, the size therefore remains at the default of
0x0. Webrender subsequently receives a display list and queries the widget size, and therefore sets the document view rect to an empty rect here. This means when the compositor eventually does get resumed properly, webrender believes there is nothing to render. I think this also makes APZ not work, meaning scrolling around does not cause a new display list to be sent, so we get stuck in this state. The only way out of it I've found is the force the window size to change, eg by opening the keyboard.
We can avoid this by initializing the
AndroidCompositorWidget with a default size.