telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
25.93k stars 5.13k forks source link

Animated stickers can overheat the CPU #27837

Closed grepwood closed 4 months ago

grepwood commented 4 months ago

Steps to reproduce

  1. Install Telegram 4.16.8 from rpmfusion-free-updates on Fedora 39
  2. Have the sticker selection on the right hand side
  3. Open a conversation and slide the sticker selection such that there's gonna be a lot of animated stickers visible
  4. Hover your mouse over to the stickers to force Telegram to play all their animations

Expected behaviour

Displaying many animated stickers on Telegram should have no dramatic impact on the CPU temperature.

Actual behaviour

On Ryzen 5700X, the temperature goes up to 96C, then the temperature increase stops and some stickers may experience lag when playing their animation. On Ryzen 7900, this is a reliable way to crash the system.

Operating system

Fedora Linux 39 KDE

Version of Telegram Desktop

4.16.8

Installation source

Other (unofficial) source

Crash ID

No response

Logs

No response

ilya-fedin commented 4 months ago

Perhaps this means you have bad cooling? tdesktop draws on CPU so high CPU load is expected. If you don't like this, you can use web version as browsers usually draw with GPU.

grepwood commented 4 months ago

@Aokromes it's not completed. You're not helping. @ilya-fedin this is on NoFan CR-80EH so you can expect the system to idle at 54-63C, this is perfectly normal in such a circumstance. On another system with the same cooler, but one which uses Ryzen 2700 on Gentoo (and thus Telegram Desktop from Portage), this issue does not exist. What codec is used to animate the stickers?

Edit: Sorry, I missed the part about drawing on CPU. Maybe, just maybe, the animation of stickers can be offloaded to OpenGL? What are the prospects for this? https://webhamster.com/ is also drawn on CPU by the browser and there's no such issue.

ilya-fedin commented 4 months ago

Maybe, just maybe, the animation of stickers can be offloaded to OpenGL?

Only if you would write an implementation. No one else has time/motivation for this. But offloading only stickers wouldn't really help as lots of time is likely to be spent in Qt while compositing CPU and GPU driven parts of the UI. Qt copies content of entire window right now when compositing and that's likely why it's worse than your browser. To solve that, one has to rewrite entire tdesktop to Electron, Flutter or QtQuick. I'm doubt anyone would do that, there are already web clients wrapped in Electron which are such modern GPU-driven clients.

ilya-fedin commented 4 months ago

it's not completed. You're not helping.

It's completed. If you want a GPU-driven client, switch to web clients. No one will rewrite tdesktop.

grepwood commented 4 months ago

Only if you would write an implementation. No one else has time/motivation for this

Could you tell me please which part of the code does this?

Qt copies content of entire window right now when compositing and that's likely why it's worse than your browser

Is this a new behavior in Qt6? The Gentoo system I have still compiles Telegram against Qt5 and there's no such issues there.

To solve that, one has to rewrite entire tdesktop to Electron

Poor RAM.

Flutter

I don't think this is a viable choice, Google just laid off a lot of people working on it.

Thank you for your patient and informative response.

ilya-fedin commented 4 months ago

Could you tell me please which part of the code does this?

Well, the problem is entire codebase, as it's written in QtWidgets which is CPU-based. All the widgets in https://github.com/desktop-app/lib_ui and tdesktop itself have to be rewritten from QPainter to OpenGL. The stickers themselves are decoded with https://github.com/Samsung/rlottie and wrapped into QImages with https://github.com/desktop-app/lib_lottie but porting only them to OpenGL is unlikely to provide any improvement as the problem is with compositing the window by Qt rather than decoding the stickers.

Is this a new behavior in Qt6?

Yeah, since Qt 6.4, when they ported QtWidgets compositing from direct OpenGL to RHI.

Poor RAM.

Seem to be ok for most of people... And apparently better than poor CPU.