[GTK4] Using GtkMediaFile increases CPU usage substantially compared with using GtkVideo without GtkMediaFile
Steps to reproduce
- Play a video using gtk_video_new_for_filename
- Play the same video using gtk_media_file_new_for_filename and gtk_video_new_for_media_stream
Current behavior
Depending on the input video I see CPU usage increase dramatically when using MediaFile, regardless of whether I'm using opengl or cairo rendering. GPU core utilization seems unaffected. For some of my sample videos, the CPU usage (zen+ architecture) as a percentage of one core is (reported by top):
GtkVideo | GtkMediaFile + GtkVideo |
---|---|
6-7% | 20-22% |
25-35% | 65-75% |
7-8.5% | 65-85% |
With the cairo renderer the absolute CPU usage increases (sometimes to over 140% of one core) but the deltas remain more or less the same.
Expected outcome
I would expect them to be within margin of error of each other.
Version information
GTK 4.2, Fedora 34, X11/i3/picom
Additional information
I first debugged this when trying to swap out GtkVideo for GtkPicture + GtkMediaFile to hide the controls. I initially thought it was an issue with GtkPicture being somehow less efficient but the same behaviour happens with GtkVideo. I ultimately decided to just hide the controls for GtkVideo since I can't preload the video data anyway due to #4062