Open Bug 1649110 Opened 5 years ago Updated 9 days ago

Add AImageReader with MediaCodec support on Android

Categories

(Core :: Graphics, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: sotaro, Assigned: jnicol)

References

(Blocks 5 open bugs)

Details

Attachments

(8 obsolete files)

Blocks: 1562818
Summary: Add AImageReader. support on Android → Add AImageReader support on Android
Depends on: 1648411

Comment from bug 1639280 comment 32

Maybe Chromium uses ImageReader only for Android P and later because Image::getHardwareBuffer() is available since that version.

The document does mention some use cases are not supported and MediaCodec is one of them. However, Android source code suggests that the HardwareBuffer is created using GraphicBuffer and should be compatible with MediaCodec.

Severity: -- → N/A
Priority: -- → P3
Blocks: 1548116
Blocks: 1526207
Assignee: nobody → sotaro.ikeda.g
Attachment #9166490 - Attachment is obsolete: true
Attached patch wip patch (obsolete) — Splinter Review
Depends on: 1657262
Attached patch wip patch (obsolete) — Splinter Review
Attachment #9167645 - Attachment is obsolete: true
Attached patch wip patch (obsolete) — Splinter Review
Attachment #9168151 - Attachment is obsolete: true
Attached patch patch_tmp_aimagereader (obsolete) — Splinter Review
Attachment #9168476 - Attachment is obsolete: true
Depends on: 1657773
Attached patch wip patch (obsolete) — Splinter Review
Attachment #9168496 - Attachment is obsolete: true
Attached patch wip (obsolete) — Splinter Review
Attachment #9168666 - Attachment is obsolete: true
Attachment #9171644 - Attachment description: patch_tmp_aimagereader → wip
See Also: → 1634578
Summary: Add AImageReader support on Android → Add AImageReader usage support to MediaCodec on Android
Attachment #9171644 - Attachment is obsolete: true
Summary: Add AImageReader usage support to MediaCodec on Android → Add AImageReader with MediaCodec support on Android
Attachment #9180349 - Attachment description: Bug 1649110 - Add AImageReader usage support to MediaCodec on Android → Bug 1649110 - Add AImageReader with MediaCodec support on Android
No longer blocks: 1526207

Sorry, there was a problem with the detection of inactive users. I'm reverting the change.

Assignee: nobody → sotaro.ikeda.g
Blocks: 1810659
Depends on: 1811424
Blocks: 1811424
No longer depends on: 1811424
Depends on: 1706656
Depends on: 1811435
Blocks: 1526207
Attachment #9180349 - Attachment is obsolete: true
Assignee: sotaro.ikeda.g → jnicol

When I implemented the wip patch, it worked well locally. But the patch caused out of descriptor crashes on some devices. And a lot of CI tests failures happened. The CI tests failures seemed to be related to GeckoSurface implementation. At the time, GeckoSurface was inherited from android Surface. It was changed as not to inherited from android Surface by Bug 1706656.

The file descriptor seemed to be increased by allocating GeckoSurface of video decoding. Passing AHardwareBuffer from content process to GPU process/Parent process and passing android Fence fd from parent side to content process seemed to increase file descirptor usage. Then it seems necessary to move the GeckoSurface allocation to GPU process to void AHardwareBuffer delivery via cross process IPC like hardware video decoding on Windows.

And gecko needs a mechanism to limit amount of dequeued video buffer. Some hardware caused a rendering problem when a lot of video buffers were dequeued from video decoder. In chromium, ImageReaderGLOwner does it. And NumRequiredMaxImages() decides amount of max dequeued images.

It seems necessary to move Codec proxy in GPU process and need to change how to call java::CodecProxy::ReleaseOutput() even when AImageReader is used.

Gecko calls CodecProxy::ReleaseOutput() from RemoteVideoDecoder in content process. It enqueues video frame to SurfaceTexture when it is decided to forward to GPU process via ImageContainer. Then SurfaceTexture has multiple enqueued video frames. It caused a problem of how to synchronize video rendering at WebRender. SurfaceTexture could render only front buffer(video frame). Then RenderAndroidSurfaceTextureHost becomes a bit complex and the video frame synchronization problem still exist. Since there are cases that video frames were dropped at WebRenderImageHost.

If we want to support WebCodecs on Android, we do not want to enqueue multiple video frames to SurfaceTexture. Otherwise, we could not select the target video frame correctly.

chromium actually does it. video frame is pushed to SurfaceTexture by calling CodecOutputBuffer::ReleaseToSurface().

There is a time gap from CodecOutputBuffer::ReleaseToSurface() until video frame available in SurfaceTexture. CodecBufferWaitCoordinator::WaitForFrameAvailable() does the wait.

Just a note that our rewrite to using C++ in the NDK, and consequently running the Android decoding operations from the GPU process has landed in https://bugzilla.mozilla.org/show_bug.cgi?id=1934009 and related bugs. It is enabled by default.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: