Closed Bug 1636085 Opened 9 months ago Closed 8 months ago

GL errors running dom/media/mediasession/test/test_active_mediasession_within_page.html on android webrender

Categories

(Core :: Graphics: WebRender, defect)

defect

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox-esr68 --- unaffected
firefox76 --- unaffected
firefox77 --- unaffected
firefox78 --- fixed

People

(Reporter: jnicol, Assigned: jnicol)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Trying to get the mochitests running on the android emulator I encountered GL errors (meaning assertion failures in debug builds) in dom/media/mediasession/test/test_active_mediasession_within_page.html. Not sure what effect this'll have on release builds on devices.

It seems to either fail with a GL_INVALID_VALUE in tex_sub_image_2d_pbo(), or glCheckFrameBufferStatus() returning GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT in Device::init_fbos().

This is a recent regression, from bug 1628175.

Set release status flags based on info from the regressing bug 1628175

Bug 1628175 seems to have had follow-up commits. Did they change anything? Are you actively investigating this?

Flags: needinfo?(jnicol)

The follow ups didn't change anything, and I am actively investigating. It seems likely that this is just an emulator bug, however: I couldn't reproduce on a real device. So it's not particularly high priority.

Flags: needinfo?(jnicol)
Blocks: wr-android-testing
No longer blocks: 1585050

This is a strange bug indeed, but I'm sure it's just an emulator bug. It also only occurs when running Android version 7 or earlier in the emulator (which is what ./mach android-emulator and our CI runs do). If you create an AVD with version 8 or later in Android Studio, then you cannot reproduce it.

Bug 1628175 made it so that RGBA surfaces from Canvases are now promoted directly to compositor surfaces. The relevant effect of this is that they now get renderered with the shader composite_TEXTURE_EXTERNAL rather than brush_image_TEXTURE_EXTERNAL. The GL errors occur just because of the fact that composite_TEXTURE_EXTERNAL is bound, even if we comment out actually drawing any triangles with it. They seem to occur when subsequently binding FBOs or uploading data to the GPU cache texture. The problem clearly isn't just because TEXTURE_EXTERNAL is completely broken, because binding brush_image_TEXTURE_EXTERNAL is fine.

I believe the problem is due to the emulator's emulation of GL_TEXTURE_EXTERNAL_OES on top of GL_TEXTURE_2D. When webrender binds a texture to GL_TEXTURE_EXTERNAL_OES, the emulator translates that in to binding to GL_TEXTURE_2D on the host OpenGL implementation. This means it has to do a lot of juggling around of which textures are bound to which target. See here for an example, though I couldn't obviously see where the bug is just by reading the code.

I think the key difference between the composite shader and the brush_image, is that the brush_image shader samples from the GPU cache whereas composite does not. Perhaps for the brush shader we therefore ensure the GPU cache is bound to a certain texture unit (which is not ever used for TEXTURE_EXTERNAL), and this ensures that the GL emulation layer knows the GPU cache texture is a TEXTURE_2D. But in the composite case we don't bind the GPU cache so it skips some bookkeeping. Then when we update the GPU cache, we bind the GPU cache texture to unit 0, which previously had a TEXTURE_EXTERNAL bound to it. It gets confused and thinks the GPU cache texture is a TEXTURE_EXTERNAL, and we get the errors.

That's just a hunch, and I can't say for certain. However, by calling glBindTexture(GL_TEXTURE_EXERNAL_OES, 0) immediately before any glBindTexture(GL_TEXTURE_2D, tex), we do indeed avoid the issue.

The severity field is not set for this bug.
:jbonisteel, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jbonisteel)

The android emulator appears to have a bug in its OpenGL
implementation where it gets confused about whether a texture is bound
to GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_2D. This was causing spurious
errors when attempting to use a regular 2D texture, due to the fact
that an external texture had previously been bound.

Work around this by explicitly unbinding from GL_TEXTURE_EXTERNAL_OES
immediately before binding to GL_TEXTURE_2D.

Pushed by jnicol@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b9d97c8a708e
Unbind GL_TEXTURE_EXTERNAL_OES before binding GL_TEXTURE_2D. r=gw
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78
Severity: -- → S3
Flags: needinfo?(jbonisteel)
You need to log in before you can comment on or make changes to this bug.