forked from quickshell/quickshell
		
	wayland/screencopy: handle buffer creation failures
This commit is contained in:
		
							parent
							
								
									ab096b7e78
								
							
						
					
					
						commit
						91c9db581e
					
				
					 4 changed files with 30 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -69,6 +69,11 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
 | 
			
		|||
		qCDebug(logBuffer) << "    Format" << format;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (request.width == 0 || request.height == 0) {
 | 
			
		||||
		qCWarning(logBuffer) << "Cannot create zero-sized buffer.";
 | 
			
		||||
		return nullptr;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!dmabufDisabled) {
 | 
			
		||||
		if (auto* buf = this->p->dmabuf.createDmabuf(request)) return buf;
 | 
			
		||||
		qCWarning(logBuffer) << "DMA buffer creation failed, falling back to SHM.";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,6 +103,16 @@ void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_flags(uint32_t
 | 
			
		|||
 | 
			
		||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_buffer_done() {
 | 
			
		||||
	auto* backbuffer = this->mSwapchain.createBackbuffer(this->request);
 | 
			
		||||
 | 
			
		||||
	if (!backbuffer || !backbuffer->buffer()) {
 | 
			
		||||
		qCWarning(logScreencopy) << "Backbuffer creation failed for screencopy. Skipping frame.";
 | 
			
		||||
 | 
			
		||||
		// Try again. This will be spammy if the compositor continuously sends bad frames.
 | 
			
		||||
		this->destroy();
 | 
			
		||||
		this->captureFrame();
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this->copy(backbuffer->buffer(), this->copiedFirstFrame ? 0 : 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,6 +117,12 @@ void IccScreencopyContext::doCapture() {
 | 
			
		|||
	auto newBuffer = false;
 | 
			
		||||
	auto* backbuffer = this->mSwapchain.createBackbuffer(this->request, &newBuffer);
 | 
			
		||||
 | 
			
		||||
	if (!backbuffer || !backbuffer->buffer()) {
 | 
			
		||||
		qCWarning(logIcc) << "Backbuffer creation failed for screencopy. Waiting for updated buffer "
 | 
			
		||||
		                     "creation parameters before trying again.";
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this->IccCaptureFrame::init(this->IccCaptureSession::create_frame());
 | 
			
		||||
	this->IccCaptureFrame::attach_buffer(backbuffer->buffer());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,6 +111,15 @@ void WlrScreencopyContext::zwlr_screencopy_frame_v1_flags(uint32_t flags) {
 | 
			
		|||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_buffer_done() {
 | 
			
		||||
	auto* backbuffer = this->mSwapchain.createBackbuffer(this->request);
 | 
			
		||||
 | 
			
		||||
	if (!backbuffer || !backbuffer->buffer()) {
 | 
			
		||||
		qCWarning(logScreencopy) << "Backbuffer creation failed for screencopy. Skipping frame.";
 | 
			
		||||
 | 
			
		||||
		// Try again. This will be spammy if the compositor continuously sends bad frames.
 | 
			
		||||
		this->destroy();
 | 
			
		||||
		this->captureFrame();
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (this->copiedFirstFrame) {
 | 
			
		||||
		this->copy_with_damage(backbuffer->buffer());
 | 
			
		||||
	} else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue