From c756217b1651479b36c106e500914c852a4bf9cb Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 15 Jan 2026 12:17:21 +0100 Subject: [PATCH] try to reduce memory consumption when displaying an animated image #LINQT-2343 --- .../Display/Chat/AnimatedImageFileView.qml | 3 ++- .../view/Control/Display/Chat/ChatMessage.qml | 2 +- .../Control/Display/Chat/ChatMessageContent.qml | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Linphone/view/Control/Display/Chat/AnimatedImageFileView.qml b/Linphone/view/Control/Display/Chat/AnimatedImageFileView.qml index b817cc9b5..a867711f3 100644 --- a/Linphone/view/Control/Display/Chat/AnimatedImageFileView.qml +++ b/Linphone/view/Control/Display/Chat/AnimatedImageFileView.qml @@ -24,7 +24,8 @@ AnimatedImage { autoTransform: true fillMode: Image.PreserveAspectFit source: contentGui && UtilsCpp.isAnimatedImage(contentGui.core.filePath) ? ('file:/'+ contentGui.core.filePath) : "" - + // sourceSize.width: implicitWidth + // sourceSize.height: implicitHeight states: State { name: 'hovered' } diff --git a/Linphone/view/Control/Display/Chat/ChatMessage.qml b/Linphone/view/Control/Display/Chat/ChatMessage.qml index dd41a9dac..8134dea90 100644 --- a/Linphone/view/Control/Display/Chat/ChatMessage.qml +++ b/Linphone/view/Control/Display/Chat/ChatMessage.qml @@ -27,7 +27,7 @@ Control.Control { property var msgState: chatMessage ? chatMessage.core.messageState : LinphoneEnums.ChatMessageState.StateIdle hoverEnabled: true property bool linkHovered: false - property real maxWidth: parent?.width || Utils.getSizeWithScreenRatio(300) + property real maxWidth: parent ? parent.width : Utils.getSizeWithScreenRatio(300) leftPadding: isRemoteMessage ? Utils.getSizeWithScreenRatio(5) : 0 diff --git a/Linphone/view/Control/Display/Chat/ChatMessageContent.qml b/Linphone/view/Control/Display/Chat/ChatMessageContent.qml index 024ed8890..e983b0f95 100644 --- a/Linphone/view/Control/Display/Chat/ChatMessageContent.qml +++ b/Linphone/view/Control/Display/Chat/ChatMessageContent.qml @@ -81,6 +81,7 @@ ColumnLayout { // SINGLE FILE ImageFileView { id: singleImageFile + cache: false visible: mainItem.filescontentProxy.count === 1 && source !== "" && UtilsCpp.isImage(contentGui.core.filePath) contentGui: mainItem.filescontentProxy.count === 1 ? mainItem.filescontentProxy.getChatMessageContentAtIndex(0) @@ -99,6 +100,22 @@ ColumnLayout { Layout.preferredHeight: paintedHeight Layout.alignment: Qt.AlignHCenter fillMode: Image.PreserveAspectFit + cache: false + property int initialSourceWidth + property int initialSourceHeight + property bool initialization: true + onStatusChanged: { + if (status == Image.Ready) { + if (singleAnimatedImageFile.initialization) { + initialSourceWidth = sourceSize.width + initialSourceHeight = sourceSize.height + singleAnimatedImageFile.initialization = false + } + var sourceW = Math.min(initialSourceWidth, mainItem.maxWidth) + sourceSize.height = Math.round((sourceW/initialSourceWidth) * initialSourceHeight) + sourceSize.width = sourceW + } + } } VideoFileView { id: singleVideoFile