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; }
69
69
qCDebug (logBuffer) << " Format" << format;
70
70
}
71
71
72
+ if (request.width == 0 || request.height == 0 ) {
73
+ qCWarning (logBuffer) << " Cannot create zero-sized buffer." ;
74
+ return nullptr ;
75
+ }
76
+
72
77
if (!dmabufDisabled) {
73
78
if (auto * buf = this ->p ->dmabuf .createDmabuf (request)) return buf;
74
79
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
103
103
104
104
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_buffer_done () {
105
105
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
+
106
116
this ->copy (backbuffer->buffer (), this ->copiedFirstFrame ? 0 : 1 );
107
117
}
108
118
Original file line number Diff line number Diff line change @@ -117,6 +117,12 @@ void IccScreencopyContext::doCapture() {
117
117
auto newBuffer = false ;
118
118
auto * backbuffer = this ->mSwapchain .createBackbuffer (this ->request , &newBuffer);
119
119
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
+
120
126
this ->IccCaptureFrame ::init (this ->IccCaptureSession ::create_frame ());
121
127
this ->IccCaptureFrame ::attach_buffer (backbuffer->buffer ());
122
128
Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ void WlrScreencopyContext::zwlr_screencopy_frame_v1_flags(uint32_t flags) {
111
111
void WlrScreencopyContext::zwlr_screencopy_frame_v1_buffer_done () {
112
112
auto * backbuffer = this ->mSwapchain .createBackbuffer (this ->request );
113
113
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
+
114
123
if (this ->copiedFirstFrame ) {
115
124
this ->copy_with_damage (backbuffer->buffer ());
116
125
} else {
You can’t perform that action at this time.
0 commit comments