backend.egl: Early return on dead buffers (#352)
This commit is contained in:
parent
c136cd5f34
commit
e3522dfb34
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
- EGLBufferReader now checks if buffers are alive before using them.
|
||||||
|
|
||||||
## version 0.3.0 (2021-07-25)
|
## version 0.3.0 (2021-07-25)
|
||||||
|
|
||||||
Large parts of Smithay were changed with numerous API changes. It is thus recommended to
|
Large parts of Smithay were changed with numerous API changes. It is thus recommended to
|
||||||
|
|
|
@ -535,7 +535,7 @@ impl EGLDisplay {
|
||||||
ffi::egl::BindWaylandDisplayWL(**self.display, display.c_ptr() as *mut _)
|
ffi::egl::BindWaylandDisplayWL(**self.display, display.c_ptr() as *mut _)
|
||||||
})
|
})
|
||||||
.map_err(Error::OtherEGLDisplayAlreadyBound)?;
|
.map_err(Error::OtherEGLDisplayAlreadyBound)?;
|
||||||
let reader = EGLBufferReader::new(self.display.clone(), display.c_ptr());
|
let reader = EGLBufferReader::new(self.display.clone(), display.c_ptr(), self.logger.clone());
|
||||||
let mut global = BUFFER_READER.lock().unwrap();
|
let mut global = BUFFER_READER.lock().unwrap();
|
||||||
if global.as_ref().and_then(|x| x.upgrade()).is_some() {
|
if global.as_ref().and_then(|x| x.upgrade()).is_some() {
|
||||||
warn!(
|
warn!(
|
||||||
|
@ -545,6 +545,7 @@ impl EGLDisplay {
|
||||||
}
|
}
|
||||||
*global = Some(WeakBufferReader {
|
*global = Some(WeakBufferReader {
|
||||||
display: Arc::downgrade(&self.display),
|
display: Arc::downgrade(&self.display),
|
||||||
|
logger: self.logger.clone(),
|
||||||
});
|
});
|
||||||
Ok(reader)
|
Ok(reader)
|
||||||
}
|
}
|
||||||
|
@ -672,11 +673,13 @@ fn get_dmabuf_formats(
|
||||||
pub struct EGLBufferReader {
|
pub struct EGLBufferReader {
|
||||||
display: Arc<EGLDisplayHandle>,
|
display: Arc<EGLDisplayHandle>,
|
||||||
wayland: Option<Arc<*mut wl_display>>,
|
wayland: Option<Arc<*mut wl_display>>,
|
||||||
|
logger: ::slog::Logger,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_system_lib")]
|
#[cfg(feature = "use_system_lib")]
|
||||||
pub(crate) struct WeakBufferReader {
|
pub(crate) struct WeakBufferReader {
|
||||||
display: Weak<EGLDisplayHandle>,
|
display: Weak<EGLDisplayHandle>,
|
||||||
|
logger: ::slog::Logger,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_system_lib")]
|
#[cfg(feature = "use_system_lib")]
|
||||||
|
@ -685,6 +688,7 @@ impl WeakBufferReader {
|
||||||
Some(EGLBufferReader {
|
Some(EGLBufferReader {
|
||||||
display: self.display.upgrade()?,
|
display: self.display.upgrade()?,
|
||||||
wayland: None,
|
wayland: None,
|
||||||
|
logger: self.logger.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -694,10 +698,16 @@ unsafe impl Send for EGLBufferReader {}
|
||||||
|
|
||||||
#[cfg(feature = "use_system_lib")]
|
#[cfg(feature = "use_system_lib")]
|
||||||
impl EGLBufferReader {
|
impl EGLBufferReader {
|
||||||
fn new(display: Arc<EGLDisplayHandle>, wayland: *mut wl_display) -> Self {
|
fn new<L>(display: Arc<EGLDisplayHandle>, wayland: *mut wl_display, log: L) -> Self
|
||||||
|
where
|
||||||
|
L: Into<Option<::slog::Logger>>,
|
||||||
|
{
|
||||||
|
let logger = crate::slog_or_fallback(log.into()).new(o!("smithay_module" => "egl_buffer_reader"));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
display,
|
display,
|
||||||
wayland: Some(Arc::new(wayland)),
|
wayland: Some(Arc::new(wayland)),
|
||||||
|
logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,6 +719,11 @@ impl EGLBufferReader {
|
||||||
&self,
|
&self,
|
||||||
buffer: &WlBuffer,
|
buffer: &WlBuffer,
|
||||||
) -> ::std::result::Result<EGLBuffer, BufferAccessError> {
|
) -> ::std::result::Result<EGLBuffer, BufferAccessError> {
|
||||||
|
if !buffer.as_ref().is_alive() {
|
||||||
|
debug!(self.logger, "Suplied buffer is no longer alive");
|
||||||
|
return Err(BufferAccessError::NotManaged(EGLError::BadParameter));
|
||||||
|
}
|
||||||
|
|
||||||
let mut format: i32 = 0;
|
let mut format: i32 = 0;
|
||||||
let query = wrap_egl_call(|| unsafe {
|
let query = wrap_egl_call(|| unsafe {
|
||||||
ffi::egl::QueryWaylandBufferWL(
|
ffi::egl::QueryWaylandBufferWL(
|
||||||
|
@ -825,6 +840,11 @@ impl EGLBufferReader {
|
||||||
&self,
|
&self,
|
||||||
buffer: &WlBuffer,
|
buffer: &WlBuffer,
|
||||||
) -> Option<crate::utils::Size<i32, crate::utils::Physical>> {
|
) -> Option<crate::utils::Size<i32, crate::utils::Physical>> {
|
||||||
|
if !buffer.as_ref().is_alive() {
|
||||||
|
debug!(self.logger, "Suplied buffer is no longer alive");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let mut width: i32 = 0;
|
let mut width: i32 = 0;
|
||||||
if unsafe {
|
if unsafe {
|
||||||
ffi::egl::QueryWaylandBufferWL(
|
ffi::egl::QueryWaylandBufferWL(
|
||||||
|
|
Loading…
Reference in New Issue