weblayer: Do not resize surface for soft keyboard
Resizing a Surface is really destroying and reallocating a Surface, and then sending it to the GPU process and have it re-composite and re-raster everything. This is a bit expensive and can cause visual glitches when keyboard gets hidden and the view grows in size instead. So follow chrome's behavior in weblayer and avoid resizing the Surface. Note that resizing the web content may also be expensive and can cause similar glitches. Chrome does not address this, neither does this CL. The main code change is keep calling WebContents.setSize, but no longer resize the SurfaceView or call onPhysicalBackingSizeChanged. Do this by introducing SurfaceParent which is a FrameLayout that sits between ContentViewRenderView and the SurfaceView in the view hierarchy. ContentViewRenderView will keep resizing for soft keyboard, and its size controls WebContents.setSize. The SurfaceParent will attempt to detect cases where it is being resized for soft keyboard, and not resize in that case. SurfaceView inherits the size from SurfaceParent, and thus not recreate the Surface if it's not resized. Conditions for when to apply this heuristic: * Only use this for SurfaceView. TextureView is more likely being used in embedded use cases where this does not apply. * ContentViewRenderView is the full width of the window. Again a heuristic to check for embedded use cases. * Soft keyboard is showing. Bug: 1050415 Change-Id: I9702f9ba06a4ab6c3d72355178bf47abf0d2240b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087972Reviewed-by:Scott Violet <sky@chromium.org> Commit-Queue: Bo <boliu@chromium.org> Cr-Commit-Position: refs/heads/master@{#747372}
Showing
Please register or sign in to comment