Bug 377859 - High CPU usage while idle.
Summary: High CPU usage while idle.
Status: CLOSED FIXED
Alias: None
Product: kdenlive
Classification: Applications
Component: User Interface (show other bugs)
Version: Appimage - Refactoring
Platform: Debian stable Linux
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords:
: 386773 386919 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-03-20 22:44 UTC by skoupad-bugzilla
Modified: 2018-03-25 18:17 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
CPU usage (136.11 KB, image/jpeg)
2017-09-22 11:32 UTC, skoupad-bugzilla
Details
CPU usage (172.21 KB, image/jpeg)
2017-09-22 11:34 UTC, skoupad-bugzilla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description skoupad-bugzilla 2017-03-20 22:44:58 UTC
I just started learning Kdenlive and I noticed something strange. I am using Debian 8.7 and an Appimage of Kdelive Version 16.12.2.  When I run Kdenlive from the Appimage I see unexpected CPU usage in idle. I've found out that if I do the following steps it stops:

 -If I press play and then pause (with or without any videos inside the project) with the Clip Monitor Tab selected, the CPU usage returns back to normal.

 -If I do anything in Kdenlive (like selecting the Project Monitor Tab) the CPU usage rises again. In order to stop it I have to select the Clip Monitor Tab and press play and pause again (the CPU usage stops only after pressing pause).
Comment 1 skoupad-bugzilla 2017-03-25 14:40:34 UTC
Additional info:

I think the bug has to do with the sound settings. By default the Kdenlive Appimage comes configured with "Audio driver: Automatic".

If I set it to "Audio driver: OSS" I see significantly less CPU usage.

Logically it shouldn't have any CPU usage on a newly started project that has no files in it (why process sound that isn't there?).

Another thought that crossed my mind is that it may be pulseaudio that is the problem. I've read many cases on the internet (with various programs) about pulseaudio using CPU excessively.
Comment 2 skoupad-bugzilla 2017-03-31 19:20:20 UTC
Additional info:

As I suspected, the problem is most likely related to pulseaudio. Searching for a solution I stumbled across some bug reports on various distros that suggested to try inserting the following line to /etc/pulse/default.pa :

load-module module-udev-detect tsched = 0

This indeed fixed the problem. But it messes up gnome sound so I can't use this solution. To my understanding the issue has to do with some problems in the alsa drivers and pulseaudio scheduler. Debian 8 uses an old version of pulseaudio and Debian 9 is just around the corner. Maybe the bug is fixed in the newer versions of pulseaudio. So, I don't know if this is actually a Kdenlive bug.
Comment 3 skoupad-bugzilla 2017-06-21 11:50:51 UTC
Additional info:

 I've just updated to Debian 9. Unfortunately the problem is still here. I was hopping that with a new clean install (and updated software) that the problem will go away. I have tested the Appimage version 17.04.1b on a clean Debian 9 fresh installation without changing anything. When I first run Kdenlive the CPU usage goes to 30%. That is with the Audio driver setting set to Automatic. If I change it to PulseAudio the CPU drops to 10%. If I add a video file the CPU usage raises up a bit. Without the video playing and without adding any filters or effects. And if I close Kdenlive completely the CPU usage returns to normal.

 I have also noticed that if I open the settings window (Settings > Configure Kdenlive) the CPU usage returns to normal. In fact if the focus is anywhere else than the main window of Kdenlive (for ex. in a Nautilus window) the problem goes away. If I click back to the main Kdenlive window to give it the focus then the problem is back. (Except with the Audio driver setting set to Automatic. In that case the CPU remains high).
Comment 4 skoupad-bugzilla 2017-09-22 11:32:58 UTC
Created attachment 107949 [details]
CPU usage

Giving focus to the main window increases the CPU usage.
Comment 5 skoupad-bugzilla 2017-09-22 11:34:16 UTC
Created attachment 107950 [details]
CPU usage
Comment 6 skoupad-bugzilla 2017-09-22 11:35:34 UTC
Additional info:

I've just tried kdenlive-alpha1-17.12 AppImage (In the About window says: version 17.11.70) and I see the same behavior. Giving focus to the main window increases the CPU usage. Giving focus anywhere else (even on another Kdenlive window), the CPU returns to normal. Does anyone else see this behavior?
Comment 7 Christoph Feck 2017-09-22 12:24:35 UTC
Yes, using version fdbbf2127 I see the same behavior. As long as the main window is active, I have constant 25% CPU usage.
Comment 8 Jean-Baptiste Mardelle 2017-09-22 15:22:02 UTC
I can confirm the issue. Wondering if that could be related to the Qt version (5.7.0) used for the build.. I am investigating...
Comment 9 Jean-Baptiste Mardelle 2017-09-22 15:24:50 UTC
I can confirm the issue. Wondering if that could be related to the Qt version (5.7.0) used for the build. My main build using Qt 5.7.1 does not have this problem. I am investigating...
Comment 10 Christoph Feck 2017-09-22 20:31:36 UTC
Comment #7 was using Qt 5.9.1.
Comment 11 Jean-Baptiste Mardelle 2017-09-23 16:44:09 UTC
Confirmed, issue in KDE Frameworks, patch pending:
https://phabricator.kde.org/D7954
Comment 12 Jean-Baptiste Mardelle 2017-10-06 06:10:21 UTC
Git commit ba889143d684326f0b8b1988ea12073c95cc8ffe by Jean-Baptiste Mardelle.
Committed on 06/10/2017 at 06:07.
Pushed by mardelle into branch 'master'.

Fix KToolBar repaint loop
Related: bug 365050
Differential Revision: https://phabricator.kde.org/D7954

M  +10   -4    src/ktoolbar.cpp

https://commits.kde.org/kxmlgui/ba889143d684326f0b8b1988ea12073c95cc8ffe
Comment 13 David Faure 2017-10-07 16:29:15 UTC
Git commit c6191993c7e5ea4873f0635a6fac79773c9cb96c by David Faure.
Committed on 07/10/2017 at 16:29.
Pushed by dfaure into branch 'master'.

KAcceleratorManager: set icon text on actions to remove CJK markers

Summary:
This replaces the KToolBar event filter hack to solve the same issue:
when an action text appears in a menu we want the & accelerator, while in
toolbars wewant that removed. Qt takes care of it, except for the more tricky
case of CJK markers: "<chinese here> (&O)" where &O exists only to get an ascii
accelerator.
Instead of hacking the text at painting time (!) it's much more robust to
remove " (&O)" from action texts and sett hat as the icon text upfront.

With this in, we can remove the KToolBar hack which leads to endless repaints.
Related: bug 365050

Test Plan: Unittest

Reviewers: mardelle, ilic, sandsmark

Subscribers: #frameworks

Differential Revision: https://phabricator.kde.org/D7964

M  +31   -6    autotests/kacceleratormanagertest.cpp
M  +1    -0    src/CMakeLists.txt
A  +106  -0    src/common_helpers.cpp     [License: LGPL (v2+)]
A  +46   -0    src/common_helpers_p.h     [License: LGPL (v2+)]
M  +21   -0    src/kacceleratormanager.cpp

https://commits.kde.org/kwidgetsaddons/c6191993c7e5ea4873f0635a6fac79773c9cb96c
Comment 14 Christoph Feck 2017-11-29 18:05:39 UTC
*** Bug 386773 has been marked as a duplicate of this bug. ***
Comment 15 Christoph Feck 2017-11-29 18:05:50 UTC
*** Bug 386919 has been marked as a duplicate of this bug. ***