Strange FD management in DMABufSurface
Categories
(Core :: Graphics: Layers, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox96 | --- | unaffected |
firefox97 | --- | fixed |
People
(Reporter: heftig, Assigned: stransky)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 1 obsolete file)
While looking at DMABufSurface.cpp, I noticed the following code:
const EGLint attribs[] = {LOCAL_EGL_SYNC_NATIVE_FENCE_FD_ANDROID, mSyncFd,
LOCAL_EGL_NONE};
mSync = egl->fCreateSync(LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
close(mSyncFd);
mSyncFd = -1;
It closes the mSyncFd
after handing it to fCreateSync
, whether the latter succeeds or not.
However, the spec says that the FD is owned by EGL afterwards.
So EGL is responsible for closing it, not the application, and the FD should not be closed.
The other uses of fCreateSync
with an FD (e.g. SharedSurfaceAndroidHardwareBuffer
) do avoid the close:
auto rawFD = fenceFd.TakePlatformHandle();
const EGLint attribs[] = {LOCAL_EGL_SYNC_NATIVE_FENCE_FD_ANDROID, rawFD.get(),
LOCAL_EGL_NONE};
EGLSync sync = egl->fCreateSync(LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
if (!sync) {
gfxCriticalNote << "Failed to create EGLSync from fd";
return;
}
// Release fd here, since it is owned by EGLSync
Unused << rawFD.release();
The code of DMABufSurface
should also be ported to use UniqueFileHandle
to manage FDs more safely, not raw int
s and close
.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 1•3 years ago
|
||
Interesting find! This is Martins field of expertise though.
Martin, does this sound reasonable to you?
Assignee | ||
Comment 2•3 years ago
|
||
Yes, the UniqueFileHandle transition would be great.
Assignee | ||
Comment 3•3 years ago
|
||
Looks like DMABufSurface::FenceWait() is not longer used which is strange.
Assignee | ||
Comment 4•3 years ago
|
||
Updated•3 years ago
|
Assignee | ||
Comment 5•3 years ago
|
||
- Remove FenceImportFromFd() and import fence in DMABufSurface::FenceWait().
- Don't close Fence FD when fence import was sucessfull.
- Don't save EGLSync to DMABufSurface after eglClientWaitSync().
Assignee | ||
Comment 6•3 years ago
|
||
- Implement SharedSurface_DMABUF::WaitForBufferOwnership() by DMABufSurface::FenceWait().
Depends on D133901
Updated•3 years ago
|
Assignee | ||
Comment 8•3 years ago
|
||
Assignee | ||
Comment 9•3 years ago
|
||
Comment 10•3 years ago
|
||
Comment 11•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/175b3cfd1fd3
https://hg.mozilla.org/mozilla-central/rev/1023d9d498f4
Comment 12•3 years ago
|
||
The patch landed in nightly and beta is affected.
:stransky, is this bug important enough to require an uplift?
If not please set status_beta
to wontfix
.
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 13•3 years ago
|
||
No need to uplift. DMABuf surface was not used before this patch.
Assignee | ||
Updated•3 years ago
|
Description
•