Skip to content

Repaint video userpic in profile top bar only on new frames - #31244

Open
hatomist wants to merge 1 commit into
telegramdesktop:devfrom
hatomist:fix-video-userpic-repaint-loop
Open

hatomist wants to merge 1 commit into
telegramdesktop:devfrom
hatomist:fix-video-userpic-repaint-loop

Conversation

@hatomist

@hatomist hatomist commented Sep 5, 2026

Copy link
Copy Markdown

With the profile column open on a chat that has a video userpic, TopBar::paintUserpic() re-queues itself via update() on every paint. Since the default surface format uses swap interval 0 on Linux, the loop is unthrottled.

Measured on Linux/Wayland (KWin, AMD Raphael iGPU, 3840x1100 window), Flatpak 7.1.3:

  • before: ~420 backing-store flushes/s, each re-uploading the 584x473 top bar and redrawing the whole window; the process held 112-132% of the iGPU 3D engine busy time
  • after: ~30 flushes/s (the video frame rate), 4-14%

Built with the CentOS build image and verified on the same setup.

TopBar::paintUserpic() called update() from inside the paint handler
while a video userpic was playing, so every paint scheduled the next
one. With swap interval 0 on Linux nothing throttles that loop and the
window is flushed as fast as the GPU returns buffers.

Repaint from the player's UpdateVideo notification instead, like
UserpicButton does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Sep 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ilya-fedin

Copy link
Copy Markdown
Collaborator

if i read the description right, this fixes #30489?

@hatomist

hatomist commented Sep 5, 2026

Copy link
Copy Markdown
Author

Yes, looks like it. Same rendering path, just spins either on CPU raster (RHI off), or spins on gpu side with opengl/vulkan rendering.

Just tested on cpu; unpatched vs patched dev (7.2.6): 97% -> 9% CPU, ~2100 -> ~70 window commits/s.

@ilya-fedin

Copy link
Copy Markdown
Collaborator

just spins either on CPU raster (RHI off), or spins on gpu side with opengl/vulkan rendering

Are you sure? Media on main window still always draws with CPU

@hatomist

hatomist commented Sep 5, 2026

Copy link
Copy Markdown
Author

Yes, frame itself is always drawn by CPU, I missed a number in the RHI ON comparison.

Pre patch:

  • RHI on - ~90% CPU AND saturates iGPU 3D engine
  • RHI off - ~100% CPU, no GPU

Post patch:

  • RHI on: ~8% CPU, ~5% GPU
  • RHI off: ~9% CPU, no GPU

Render is CPU in both cases, downstream of that RHI ON adds a GPU step per flush: upload the dirty region, redraw the whole window. So GPU load is technically a side effect, I didn't separate the two at first properly as it mostly showed up for me as desktop/compositor lag while the 9950x3d2 host cpu didn't suffer much from one spinning core out of 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants