Repository navigation
[Impeller] Attach multisampled textures single sampled for GLES readbacks - #195887
Draft
WessimBetclic wants to merge 1 commit into
Draft
WessimBetclic wants to merge 1 commit into
WessimBetclic wants to merge 1 commit into
Conversation
…acks BlitCopyTextureToBufferCommandGLES binds GL_FRAMEBUFFER for glReadPixels since flutter#174668, so ComputeTypeForBinding no longer attaches a multisampled texture single sampled as it does for GL_READ_FRAMEBUFFER (flutter#163345). With EXT_multisampled_render_to_texture the texture Picture.toImage hands to toByteData is multisampled, and attaching it with glFramebufferTexture2DMultisampleEXT only to read it crashes some drivers or fails the framebuffer, which aborts on the blit pass FML_CHECK. SetAsFramebufferAttachment takes a for_reading flag. The readback passes it and keeps binding GL_FRAMEBUFFER. Fixes flutter#195319
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR. The problem: on Android phones where Impeller runs on OpenGL ES, reading pixels back from an image (
Image.toByteData) can crash the app; it is our top crash across five apps. The regression: #174668 (September 2025) moved the readback off the path that #163345 had made safe, and 3.47 then put most MediaTek phones on OpenGL ES, so it went from rare to constant. The fix: the readback now says it only reads the image, so it is attached the safe way again. Nothing changes for drawing.Fixes #195319: on Impeller OpenGL ES,
Image.toByteDataon aPicture.toImageresult crashes on Mali and PowerVR phones, either inside the driver or on theFML_CHECKinBlitPassGLES::EncodeCommands. It is our top crash since 3.47 moved MediaTek phones to GLES (#186405): about 7,600 users a week across our five Android apps (Crashlytics, 7 days to 2026-11-03), 30 to 60 percent of all our crashed Android users.Cause: the readback attaches the snapshot texture with
glFramebufferTexture2DMultisampleEXT. WithEXT_multisampled_render_to_texturethe snapshot texture is multisampled, andComputeTypeForBindingonly attaches such a texture single sampled onGL_READ_FRAMEBUFFER(#163345). #174668 moved the readback toGL_FRAMEBUFFERfor GLES 2, which bypassed that.Fix:
SetAsFramebufferAttachmentgets afor_readingflag that attaches a multisampled texture single sampled whatever the target. The readback passes it and still bindsGL_FRAMEBUFFER.Test:
BlitCommandGLESTest.BlitCopyTextureToBufferCommandGLESReadsMultisampledTextureSingleSampledwith the mock GL, fails on master. The mock gainsglFramebufferTexture2DMultisampleEXT.Related: #163345, #174668, #193428
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.