File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
6969 qCDebug (logBuffer) << " Format" << format;
7070 }
7171
72+ if (request.width == 0 || request.height == 0 ) {
73+ qCWarning (logBuffer) << " Cannot create zero-sized buffer." ;
74+ return nullptr ;
75+ }
76+
7277 if (!dmabufDisabled) {
7378 if (auto * buf = this ->p ->dmabuf .createDmabuf (request)) return buf;
7479 qCWarning (logBuffer) << " DMA buffer creation failed, falling back to SHM." ;
Original file line number Diff line number Diff line change @@ -103,6 +103,16 @@ void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_flags(uint32_t
103103
104104void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_buffer_done () {
105105 auto * backbuffer = this ->mSwapchain .createBackbuffer (this ->request );
106+
107+ if (!backbuffer || !backbuffer->buffer ()) {
108+ qCWarning (logScreencopy) << " Backbuffer creation failed for screencopy. Skipping frame." ;
109+
110+ // Try again. This will be spammy if the compositor continuously sends bad frames.
111+ this ->destroy ();
112+ this ->captureFrame ();
113+ return ;
114+ }
115+
106116 this ->copy (backbuffer->buffer (), this ->copiedFirstFrame ? 0 : 1 );
107117}
108118
Original file line number Diff line number Diff line change @@ -117,6 +117,12 @@ void IccScreencopyContext::doCapture() {
117117 auto newBuffer = false ;
118118 auto * backbuffer = this ->mSwapchain .createBackbuffer (this ->request , &newBuffer);
119119
120+ if (!backbuffer || !backbuffer->buffer ()) {
121+ qCWarning (logIcc) << " Backbuffer creation failed for screencopy. Waiting for updated buffer "
122+ " creation parameters before trying again." ;
123+ return ;
124+ }
125+
120126 this ->IccCaptureFrame ::init (this ->IccCaptureSession ::create_frame ());
121127 this ->IccCaptureFrame ::attach_buffer (backbuffer->buffer ());
122128
Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ void WlrScreencopyContext::zwlr_screencopy_frame_v1_flags(uint32_t flags) {
111111void WlrScreencopyContext::zwlr_screencopy_frame_v1_buffer_done () {
112112 auto * backbuffer = this ->mSwapchain .createBackbuffer (this ->request );
113113
114+ if (!backbuffer || !backbuffer->buffer ()) {
115+ qCWarning (logScreencopy) << " Backbuffer creation failed for screencopy. Skipping frame." ;
116+
117+ // Try again. This will be spammy if the compositor continuously sends bad frames.
118+ this ->destroy ();
119+ this ->captureFrame ();
120+ return ;
121+ }
122+
114123 if (this ->copiedFirstFrame ) {
115124 this ->copy_with_damage (backbuffer->buffer ());
116125 } else {
You can’t perform that action at this time.
0 commit comments