fix: prevent cursor flicker during screen recording#509
fix: prevent cursor flicker during screen recording#509zccrs merged 2 commits intolinuxdeepin:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes cursor flickering during screen recording by addressing buffer caching issues in the WBufferRenderer system. The fix removes the problematic resetTextureProvider function and improves buffer management to prevent the cursor from disappearing when switching between software and hardware cursors.
Key changes:
- Removed
WBufferRenderer::resetTextureProviderfunction that was causing buffer cache clearing - Updated buffer update logic to only modify cache when
shouldCacheBufferstate changes - Enhanced texture change signaling to handle content updates even when buffer object remains the same
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| wsgtextureprovider.cpp | Enhanced texture change signaling for buffer content updates |
| woutputrenderwindow.cpp | Removed call to resetTextureProvider during layer compositor cleanup |
| wbufferrenderer_p.h | Removed resetTextureProvider function declaration |
| wbufferrenderer.cpp | Removed resetTextureProvider implementation and improved updateTextureProvider logic |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors the buffer provider logic to stop clearing the cached buffer during cursor transitions, restricts texture provider updates to when caching state changes, and ensures texture change signals fire on content updates—eliminating cursor flicker during screen recording. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Remove `WBufferRenderer::resetTextureProvider` to avoid accidentally cleaning the cached buffer in `WBufferRenderer` when switching from a software cursor to a hardware cursor. 2. The root cause was that switching from a software cursor to a hardware cursor inadvertently cleared the cached buffer in `WBufferRenderer`, causing the buffer referenced by `BufferRendererProxy` to become null. 3. The `resetTextureProvider` function was originally introduced in the `WOutputLayer` implementation (https://github.com/vioken/waylib/ commit/ea814c44), and the buffer lock/unlock mechanism was introduced in vioken/waylib@35fdcb72. The lock/unlock mechanism is a new design, so manually resetting the buffer is no longer necessary. 4. Update `WSGTextureProvider::setBuffer` to emit `textureChanged()` signal when `buffer` is not null and the buffer object is not changed, but maybe the buffer's content is changed. Influence: 1. Verify that the cursor no longer flickers during screen recording, especially when switching between software and hardware cursors. 2. Test screen sharing and ensure that the shared content is displayed correctly without any visual artifacts. 3. Check the buffer management to ensure that buffers are properly locked and unlocked, and that no memory leaks occur. fix: 修复录屏时光标闪烁问题 1. 移除 `WBufferRenderer::resetTextureProvider` 以避免在从软光标切换到 硬光标时意外清理 `WBufferRenderer` 中的缓存 buffer。 2. 根本原因是,从软光标切换到硬光标时,无意中清除了 `WBufferRenderer` 中的缓存 buffer,导致 `BufferRendererProxy` 引用的 buffer 变为 null。 3. `resetTextureProvider` 函数最初是在 `WOutputLayer` 实现中引入的 (https://github.com/vioken/waylib/commit/ea814c44),buffer 锁/解锁机制是 在 vioken/waylib@35fdcb72 中引入的。 锁/解锁机 制是一种新的设计,因此不再需要手动重置 buffer。 4. 更新 `WSGTextureProvider::setBuffer`,当 `buffer` 不为 null 且 buffer 对象没有更改时,发出 `textureChanged()` 信号,但 buffer 的内容可 能会更改。 Influence: 1. 验证在屏幕录制过程中,尤其是在软件和硬件光标之间切换时,光标不再 闪烁。 2. 测试屏幕共享,确保共享内容显示正确,没有任何视觉伪影。 3. 检查 buffer 管理,确保 buffer 被正确锁定和解锁,并且没有发生内存 泄漏。
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zccrs, zzxyb The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WBufferRenderer::resetTextureProviderfunction, which was inadvertently clearing the cached buffer inWBufferRendererwhen switching from a software cursor to a hardware cursor during screen recording.BufferRendererProxyreferencing a null buffer after the cache was cleared. This happened becauseresetTextureProviderwas called even thoughlockCacheBufferhad been invoked without a correspondingunlockCacheBuffer. The lock/ unlock mechanism should have ensured the buffer's persistence.WBufferRenderer::updateTextureProviderto ensure buffer is only updated whenshouldCacheBufferstate is changed. If not, the buffer should be updated inWBufferRenderer::render.WSGTextureProvider::setBufferto emit thetextureChanged()signal when buffer content changed.Influence:
resetTextureProvider.fix: 修复录屏时光标闪烁问题
WBufferRenderer::resetTextureProvider函数,该函数会在录屏 期间从软件光标切换到硬件光标时,意外地清除WBufferRenderer中的缓存buffer,导致光标闪烁。
BufferRendererProxy引用了一个空 buffer。发生这种情况的原因是,即使调用了lockCacheBuffer但没有相应的unlockCacheBuffer,也会调用resetTextureProvider。lock/unlock 机制应 该确保 buffer 的持久性。WBufferRenderer::updateTextureProvider以确保仅 在shouldCacheBuffer状态更改时才更新buffer。 否则,应在WBufferRenderer::render中更新buffer。WSGTextureProvider::setBuffer在buffer 内容更改时,触发textureChanged()信号。Influence:
resetTextureProvider的影响。Summary by Sourcery
Prevent cursor flicker during screen recording by retaining the cached buffer and refining buffer update logic.
Bug Fixes:
Enhancements: