Bug 161480 - Animated gif renders with green artifacts with Skia/Raster & Metal
Summary: Animated gif renders with green artifacts with Skia/Raster & Metal
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
7.1.0.3 release
Hardware: All All
: medium normal
Assignee: Patrick (volunteer)
URL:
Whiteboard: target:25.8.0 target:24.8.5 target:25...
Keywords: bibisected, bisected, regression
: 164565 (view as bug list)
Depends on:
Blocks: Images-Animated
  Show dependency treegraph
 
Reported: 2024-06-09 06:16 UTC by Telesto
Modified: 2025-01-09 19:29 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot (2.35 MB, image/png)
2024-06-09 06:18 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2024-06-09 06:16:16 UTC
Description:
Animated gif renders with green artifacts with Skia/Raster & Metal

Steps to Reproduce:
1. Open attachment 162128 [details]

Actual Results:
See screenshot

Expected Results:
Normal rendering


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.8.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: d2eab48f697a1e6097778158f623f11306ac7a3d
CPU threads: 8; OS: macOS 14.3; UI render: Skia/Metal; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 1 Telesto 2024-06-09 06:18:52 UTC
Created attachment 194612 [details]
Screenshot
Comment 2 johnks 2024-06-09 11:58:50 UTC
confirmed 

Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba
CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-IN (en_IN); UI: en-US
Calc: threaded
Comment 3 gladys 2024-06-12 18:18:23 UTC
comfirmed
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: CL threaded

and version
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 74185b8edf7f046a3372319da86a1d8ca0024c87
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: CL threaded
Comment 4 Gabor Kelemen (allotropia) 2024-10-30 22:55:32 UTC
I can see it happening under Windows/Skia raster as early as 7.1, seems to have started in:

https://git.libreoffice.org/core/+/717ce6838b7ef0add1f9a9655e2b8c0bf60203f0%5E%21/#F0

commit 717ce6838b7ef0add1f9a9655e2b8c0bf60203f0	[log]
author	Luboš Luňák <l.lunak@collabora.com>	Sat Sep 05 07:05:16 2020 +0200
committer	Luboš Luňák <l.lunak@collabora.com>	Mon Sep 07 15:19:32 2020 +0200

avoid temporary SkImage when merging bitmaps in Skia (tdf#136244)
Comment 5 Telesto 2025-01-06 20:12:51 UTC
*** Bug 164565 has been marked as a duplicate of this bug. ***
Comment 6 Telesto 2025-01-06 20:14:52 UTC
Is this still an issue on other platforms?

I'm not seeing any issue rendering gif in the screencast here: attachment 198406 [details] 
posted at bug 161480 comment 10 with

Version: 25.2.0.1 (X86_64) / LibreOffice Community
Build ID: ddb2a7ea3a8857aae619555f1a8743e430e146c9
CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Vulkan; VCL: win
Locale: pl-PL (pl_PL); UI: en-US
Calc: CL threaded

I'm still able to reproduce it on MacOS
Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 2b68e8bc0303432625a87d6dd60d5e6c3de9be72
CPU threads: 8; OS: macOS 14.7.1; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 7 Alex Thurgood 2025-01-06 21:52:23 UTC
Still reproduced with

Version: 25.8.0.0.alpha0+ (AARCH64) / LibreOffice Community
Build ID: 022e95d39d9ae29496be0f81740eefaf515f578a
CPU threads: 8; OS: macOS 15.2; UI render: Skia/Metal; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded

Doesn't make any difference whether Skia is activated, or software raster.
Comment 8 Patrick (volunteer) 2025-01-07 01:36:34 UTC
(In reply to Telesto from comment #6)
> Is this still an issue on other platforms?
> 
> I'm not seeing any issue rendering gif in the screencast here: attachment
> 198406 [details] 
> posted at bug 161480 comment 10 with

I have uploaded the following patch that fixes this bug on macOS:

https://gerrit.libreoffice.org/c/core/+/179848

Not sure if Windows or Linux has the same issue, but what I found is that on macOS this bug occurs when upscaling images. With a Retina display on macOS, upscaling is done very frequently (because Retina holds 4 pixels of memory for every 1 pixel of screen size).

So maybe this bug might occur if Windows or Linux has a scaled display of 150% or more. But I wouldn't be surprised if this is a bug only on macOS so I limited my fix to only macOS.

If anyone has a Windows or Linux build and they can reproduce this build, try applying the following patch. This will apply my macOS fix to all platforms:

diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index 08d3ad4da44e..a0a6ea2da427 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -161,7 +161,6 @@ inline bool isUnitTestRunning(const char* name = nullptr)
 // algorithm done by VCL does as well).
 inline BmpScaleFlag goodScalingQuality(bool isGPU, bool isUpscale = false)
 {
-#ifdef MACOSX
     // tdf#161480 use BmpScaleFlag::NearestNeighbor when upscaling on macOS
     // On macOS, due to Retina window scaling, it is very common to
     // have Skia surfaces that are 2 times the size of their respective
@@ -172,9 +171,6 @@ inline BmpScaleFlag goodScalingQuality(bool isGPU, bool isUpscale = false)
     // the bitmap correctly.
     if (isUpscale)
         return BmpScaleFlag::NearestNeighbor;
-#else
-    (void)isUpscale;
-#endif
 
     return isGPU ? BmpScaleFlag::BestQuality : BmpScaleFlag::Default;
 }
Comment 9 Commit Notification 2025-01-07 12:30:32 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7ef881c76e656ece71cf6d1d472757edf5c1ff44

tdf#161480 use BmpScaleFlag::NearestNeighbor when upscaling on macOS

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 10 Patrick (volunteer) 2025-01-07 12:32:22 UTC
I have committed a fix for this bug and the fix should be in tomorrow's (08 January 2025) nightly master builds:

https://dev-builds.libreoffice.org/daily/master/current.html

Note for macOS testers: the nightly master build installer does not overwrite any LibreOffice official versions. Instead, it will be installed as a separate application called "LibreOfficeDev" in the /Applications folder.

Because this is a "test" build, you will need to do the following steps before you launch the LibreOfficeDev application:

1. Go to the Finder and navigate to the /Applications/Utilities folder
2. Launch the "Terminal" application
3. Paste the following command in the Terminal application window and press the Return key to execute the command:

   xattr -d com.apple.quarantine /Applications/LibreOfficeDev.app
Comment 11 Commit Notification 2025-01-09 19:29:28 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/df729222b251411b94cce1323067f21b4fe5335e

tdf#161480 use BmpScaleFlag::NearestNeighbor when upscaling on macOS

It will be available in 24.8.5.

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 Commit Notification 2025-01-09 19:29:31 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/31241013825be589e722ff80ac120c5f60a81107

tdf#161480 use BmpScaleFlag::NearestNeighbor when upscaling on macOS

It will be available in 25.2.0.2.

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.