Bug 166055 - Memory leak when inserting .mp4 videos in Impress (kf6)
Summary: Memory leak when inserting .mp4 videos in Impress (kf6)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
24.8.6.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Michael Weghorn
URL:
Whiteboard: target:25.8.0 target:25.2.3
Keywords:
Depends on:
Blocks: Qt6
  Show dependency treegraph
 
Reported: 2025-04-06 18:20 UTC by bilaltasdelen
Modified: 2025-04-10 09:02 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Terminal output during the bug. (1.32 KB, text/plain)
2025-04-07 17:24 UTC, bilaltasdelen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bilaltasdelen 2025-04-06 18:20:28 UTC
Description:
Whenever I try to insert an .mp4 video, either by dragging or using the insert menu, Impress starts to fill the memory, and most of the time gets killed by the OOM killer. If I am able to save before the crash or the Impress stops before getting killed, things turns to normal, and video plays, no problem. I realized that, memory is filled during the thumbnail creation, and stops if the thumbnail is created before the crash. GIFs don't seem to trigger this, but I have not tried another video format.

Steps to Reproduce:
1. Insert an mp4 into a slide in Impress. 
2. Monitor memory consumption.


Actual Results:
Memory is filled, system slows to halt, and Impress gets killed by the system.

Expected Results:
Video inserted successfully without crippling the system.


Reproducible: Always


User Profile Reset: No

Additional Info:
System memory: 32 GB
Comment 1 bilaltasdelen 2025-04-06 22:52:25 UTC
Desktop Environment: KDE Wayland 6.3.4
Integrated GPU: Intel UHD 630
Dedicated GPU: NVIDIA GeForce GTX 1650
Kernel 6.13.8
Comment 2 m_a_riosv 2025-04-07 00:38:38 UTC

*** This bug has been marked as a duplicate of bug 116643 ***
Comment 3 Buovjaga 2025-04-07 05:17:47 UTC
(In reply to m_a_riosv from comment #2)
> 
> *** This bug has been marked as a duplicate of bug 116643 ***

I don't think this is a duplicate of that report because it is about playing a slide in a Powerpoint file and this is about inserting. I have experienced this same memory leak with KDE UI, but for some reason didn't report it. I am not at my normal workstation, so can't test if it still happens with 25.2.

bilaltasdelen: can you try launching with

SAL_USE_VCLPLUGIN=gen libreoffice

or

SAL_USE_VCLPLUGIN=gtk3 libreoffice

and see if that makes a difference. You may also run htop in a different terminal, filter by soffice (F4) and manually kill the process (F9, SIGTERM), if you see the memory starting to leak.

I do see there is bug 164866 for gtk3.
Comment 4 bilaltasdelen 2025-04-07 17:24:52 UTC
Created attachment 200216 [details]
Terminal output during the bug.
Comment 5 bilaltasdelen 2025-04-07 17:25:19 UTC
With both SAL_USE_VCLPLUGIN=gen libreoffice and SAL_USE_VCLPLUGIN=gtk3 libreoffice I was able to insert the video and memory consumption was reasonable. Though, with SAL_USE_VCLPLUGIN=gen libreoffice UI was extremely laggy, and SAL_USE_VCLPLUGIN=gtk3 libreoffice froze once when I played an already inserted video (potentially reproducing bug 164866).

I should add the current version I am testing is 25.2.2.2. I was observing this behavior for some time, though.

Also, in case it is helpful, I attached the errors printed to the console during the video insertion.
Comment 6 bilaltasdelen 2025-04-07 18:35:48 UTC
Additional info: SAL_USE_VCLPLUGIN=kf5 libreoffice also seems to work, and is currently looking to be the most stable and snappy option among the others for my system. It can be a workaround for this bug.
Comment 7 Michael Weghorn 2025-04-08 06:35:06 UTC
I can't reproduce on Debian testing when inserting the Big Buck Bunny movie [1]. Do you reproduce with that particular file as well? Otherwise, can you please attach or provide a link to a sample .mp4 file that triggers this?

Please also paste the complete version information from "Help" -> "About LibreOffice for more details.

Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: b7e6e0f150a669aa191b16655e6e03d60946c416
CPU threads: 32; OS: Linux 6.12; UI render: default; VCL: qt6 (cairo+wayland)
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: CL threaded

[1] https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4
Comment 8 Michael Weghorn 2025-04-08 06:38:24 UTC
(In reply to Michael Weghorn from comment #7)
> I can't reproduce on Debian testing when inserting the Big Buck Bunny movie
> [1].

While I can't reproduce with that file with my local development build, I actually can with the Debian packaged LibreOffice version. This might be either fixed in a newer version of LibreOffice or related to something else (e.g. different QtMultiMedia video backends being used.)

Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 520(Build:2)
CPU threads: 32; OS: Linux 6.12; UI render: default; VCL: kf6 (cairo+wayland)
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Debian package version: 4:25.2.2-1
Calc: threaded
Comment 9 bilaltasdelen 2025-04-08 13:27:35 UTC
I can reproduce with Big Buck Bunny video. Sometimes first insertion works, but second insertion triggers the bug. 

Requested information:

Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 520(Build:2)
CPU threads: 12; OS: Linux 6.13; UI render: default; VCL: kf6 (cairo+wayland)
Locale: en-US (en_US.UTF-8); UI: en-US
25.2.2-1
Calc: CL threaded
Comment 10 Michael Weghorn 2025-04-09 07:55:22 UTC
(In reply to bilaltasdelen from comment #9)
> I can reproduce with Big Buck Bunny video. Sometimes first insertion works,
> but second insertion triggers the bug.

Thanks. I can indeed reproduce the issue with my local dev build as well when I try inserting a video multiple times.

Pending Gerrit change https://gerrit.libreoffice.org/c/core/+/183867 fixes the issue for me with the default ffmpeg QtMultimedia backend.

(For QT_MEDIA_BACKEND=gstreamer, the infinite recursion is also fixed with that change, but it crashes later somewhere in low-level GStreamer code, which *might* possibly be a GStreamer or Qt bug, but I didn't investigate further.)
Comment 11 Commit Notification 2025-04-09 10:20:22 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/697405b533a8ae5b6a8f5bd184b9344a96f71c69

tdf#166055 qt avmedia: Provide media/player size right away

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Michael Weghorn 2025-04-09 10:20:48 UTC
Pending backport for 25-2: https://gerrit.libreoffice.org/c/core/+/183914
Comment 13 Commit Notification 2025-04-10 09:02:19 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/2308a07698660f84e2e11b3fab8cc75550c6798d

tdf#166055 qt avmedia: Provide media/player size right away

It will be available in 25.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.