From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- image/BlobSurfaceProvider.cpp | 2 +- image/BlobSurfaceProvider.h | 2 +- image/DecodedSurfaceProvider.cpp | 6 +++++ image/ISurfaceProvider.h | 3 +++ image/SurfaceCache.cpp | 11 +++++---- image/SurfaceCache.h | 8 +++--- image/VectorImage.cpp | 2 +- image/WebRenderImageProvider.h | 5 ++-- image/imgLoader.h | 2 +- image/test/crashtests/crashtests.list | 10 ++++---- image/test/fuzzing/TestDecoders.cpp | 2 +- image/test/gtest/Common.h | 6 ++--- image/test/gtest/TestDeinterlacingFilter.cpp | 12 +++------ image/test/gtest/moz.build | 21 +++++++--------- image/test/reftest/generic/1805599-1-ref.html | 2 ++ image/test/reftest/generic/1805599-1.html | 34 ++++++++++++++++++++++++++ image/test/reftest/generic/1805599-1.png | Bin 0 -> 270408 bytes image/test/reftest/generic/1805599-1.svg | 10 ++++++++ image/test/reftest/generic/reftest.list | 1 + 19 files changed, 96 insertions(+), 43 deletions(-) create mode 100644 image/test/reftest/generic/1805599-1-ref.html create mode 100644 image/test/reftest/generic/1805599-1.html create mode 100644 image/test/reftest/generic/1805599-1.png create mode 100644 image/test/reftest/generic/1805599-1.svg (limited to 'image') diff --git a/image/BlobSurfaceProvider.cpp b/image/BlobSurfaceProvider.cpp index b50ed5bf25..c0d6057354 100644 --- a/image/BlobSurfaceProvider.cpp +++ b/image/BlobSurfaceProvider.cpp @@ -123,7 +123,7 @@ nsresult BlobSurfaceProvider::UpdateKey( return NS_ERROR_FAILURE; } -void BlobSurfaceProvider::InvalidateRecording() { +void BlobSurfaceProvider::InvalidateSurface() { MOZ_ASSERT(NS_IsMainThread()); auto i = mKeys.Length(); diff --git a/image/BlobSurfaceProvider.h b/image/BlobSurfaceProvider.h index 8222450b39..1ea1cf1cb7 100644 --- a/image/BlobSurfaceProvider.h +++ b/image/BlobSurfaceProvider.h @@ -97,7 +97,7 @@ class BlobSurfaceProvider final : public ISurfaceProvider { wr::IpcResourceUpdateQueue& aResources, wr::ImageKey& aKey) override; - void InvalidateRecording() override; + void InvalidateSurface() override; void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, const AddSizeOfCb& aCallback) override { diff --git a/image/DecodedSurfaceProvider.cpp b/image/DecodedSurfaceProvider.cpp index cdfc27bcda..f60b52018e 100644 --- a/image/DecodedSurfaceProvider.cpp +++ b/image/DecodedSurfaceProvider.cpp @@ -222,6 +222,10 @@ nsresult DecodedSurfaceProvider::UpdateKey( nsresult SimpleSurfaceProvider::UpdateKey( layers::RenderRootStateManager* aManager, wr::IpcResourceUpdateQueue& aResources, wr::ImageKey& aKey) { + if (mDirty) { + return NS_ERROR_FAILURE; + } + RefPtr surface = mSurface->GetSourceSurface(); if (!surface) { return NS_ERROR_FAILURE; @@ -230,5 +234,7 @@ nsresult SimpleSurfaceProvider::UpdateKey( return SharedSurfacesChild::Share(surface, aManager, aResources, aKey); } +void SimpleSurfaceProvider::InvalidateSurface() { mDirty = true; } + } // namespace image } // namespace mozilla diff --git a/image/ISurfaceProvider.h b/image/ISurfaceProvider.h index 03ab713238..b9241f80a5 100644 --- a/image/ISurfaceProvider.h +++ b/image/ISurfaceProvider.h @@ -314,6 +314,8 @@ class SimpleSurfaceProvider final : public ISurfaceProvider { wr::IpcResourceUpdateQueue& aResources, wr::ImageKey& aKey) override; + void InvalidateSurface() override; + protected: DrawableFrameRef DrawableRef(size_t aFrame) override { MOZ_ASSERT(aFrame == 0, @@ -338,6 +340,7 @@ class SimpleSurfaceProvider final : public ISurfaceProvider { NotNull> mSurface; DrawableFrameRef mLockRef; + bool mDirty = false; }; } // namespace image diff --git a/image/SurfaceCache.cpp b/image/SurfaceCache.cpp index 6f05bce6ff..cccbd505f5 100644 --- a/image/SurfaceCache.cpp +++ b/image/SurfaceCache.cpp @@ -181,7 +181,7 @@ class CachedSurface { return aMallocSizeOf(this) + aMallocSizeOf(mProvider.get()); } - void InvalidateRecording() { mProvider->InvalidateRecording(); } + void InvalidateSurface() { mProvider->InvalidateSurface(); } // A helper type used by SurfaceCacheImpl::CollectSizeOfSurfaces. struct MOZ_STACK_CLASS SurfaceMemoryReport { @@ -543,13 +543,14 @@ class ImageSurfaceCache { bool Invalidate(Function&& aRemoveCallback) { // Remove all non-blob recordings from the cache. Invalidate any blob // recordings. - bool foundRecording = false; + bool found = false; for (auto iter = mSurfaces.Iter(); !iter.Done(); iter.Next()) { NotNull current = WrapNotNull(iter.UserData()); + found = true; + current->InvalidateSurface(); + if (current->GetSurfaceKey().Flags() & SurfaceFlags::RECORD_BLOB) { - foundRecording = true; - current->InvalidateRecording(); continue; } @@ -558,7 +559,7 @@ class ImageSurfaceCache { } AfterMaybeRemove(); - return foundRecording; + return found; } IntSize SuggestedSize(const IntSize& aSize) const { diff --git a/image/SurfaceCache.h b/image/SurfaceCache.h index 864a6ffbc4..de4d448b00 100644 --- a/image/SurfaceCache.h +++ b/image/SurfaceCache.h @@ -424,12 +424,14 @@ struct SurfaceCache { /** * Removes all rasterized cache entries (including placeholders) associated - * with the given image from the cache. Any blob recordings are marked as - * dirty and must be regenerated. + * with the given image from the cache and marks their surface providers as + * dirty and should not be drawn again. Any blob recordings are left in th + * cache but marked as dirty and must be regenerated. * * @param aImageKey The image whose cache which should be regenerated. * - * @returns true if any recordings were invalidated, else false. + * @returns true if any surface providers were present in the cache, else + * false. */ static bool InvalidateImage(const ImageKey aImageKey); diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index eccd04e3cf..11fb990824 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -513,7 +513,7 @@ void VectorImage::SendInvalidationNotifications() { mHasPendingInvalidation = false; if (SurfaceCache::InvalidateImage(ImageKey(this))) { - // If we still have recordings in the cache, make sure we handle future + // If we had any surface providers in the cache, make sure we handle future // invalidations. MOZ_ASSERT(mRenderingObserver, "Should have a rendering observer by now"); mRenderingObserver->ResumeHonoringInvalidations(); diff --git a/image/WebRenderImageProvider.h b/image/WebRenderImageProvider.h index 84fee8cb47..af60bbf357 100644 --- a/image/WebRenderImageProvider.h +++ b/image/WebRenderImageProvider.h @@ -48,9 +48,10 @@ class WebRenderImageProvider { } /** - * Invalidate if a blob recording, requiring it to be regenerated. + * Invalidate if a blob recording or simple surface provider (both are only + * used by vector images), requiring it to be regenerated. */ - virtual void InvalidateRecording() {} + virtual void InvalidateSurface() {} protected: WebRenderImageProvider(const ImageResource* aImage); diff --git a/image/imgLoader.h b/image/imgLoader.h index 7423517925..0c3803d491 100644 --- a/image/imgLoader.h +++ b/image/imgLoader.h @@ -38,7 +38,7 @@ namespace mozilla { namespace dom { class Document; enum class FetchPriority : uint8_t; -} +} // namespace dom } // namespace mozilla class imgCacheEntry { diff --git a/image/test/crashtests/crashtests.list b/image/test/crashtests/crashtests.list index 7e137b1d09..7e5aea7fc5 100644 --- a/image/test/crashtests/crashtests.list +++ b/image/test/crashtests/crashtests.list @@ -12,7 +12,7 @@ skip-if(Android||isDebugBuild||ThreadSanitizer) load 694165-1.xhtml load 732319-1.html load 844403-1.html load 856616.gif -skip-if(wayland&&isDebugBuild) skip-if(ThreadSanitizer) load 944353.jpg # wayland: bug 1857023 +skip-if(ThreadSanitizer) load 944353.jpg load 1205923-1.html # Ensure we handle detecting that an image is animated, then failing to decode # it. (See bug 1210745.) @@ -63,10 +63,10 @@ load truncated-second-frame.png # Bug 863975 load 1509998.gif load 1526717-1.html -skip-if(ThreadSanitizer) pref(widget.windows.window_occlusion_tracking.enabled,false) load 1629490-1.html # Bug 1819154 +skip-if(ThreadSanitizer) load 1629490-1.html -pref(widget.windows.window_occlusion_tracking.enabled,false) HTTP load 1634839-1.html # Bug 1819154 -pref(widget.windows.window_occlusion_tracking.enabled,false) HTTP load 1634839-2.html # Bug 1819154 +HTTP load 1634839-1.html +HTTP load 1634839-2.html pref(image.animated.decode-on-demand.batch-size,1) pref(image.animated.decode-on-demand.threshold-kb,0) HTTP load 1676172-1.html pref(browser.soft_reload.only_force_validate_top_level_document,false) HTTP load 1763581-1.html load 1765871-1.jpg @@ -80,4 +80,4 @@ load 1814774.avif load 1817108.avif load 1848717-1.avif load 1852649.webp -pref(widget.windows.window_occlusion_tracking.enabled,false) HTTP load 1862059-1.html +HTTP load 1862059-1.html diff --git a/image/test/fuzzing/TestDecoders.cpp b/image/test/fuzzing/TestDecoders.cpp index c5c0dcdb27..20bc79330d 100644 --- a/image/test/fuzzing/TestDecoders.cpp +++ b/image/test/fuzzing/TestDecoders.cpp @@ -139,7 +139,7 @@ static int RunDecodeToSurfaceFuzzingJXL(nsCOMPtr inputStream) { int FuzzingInitImage(int* argc, char*** argv) { Preferences::SetBool("image.avif.sequence.enabled", true); - Preferences::SetBool("image.mem.max_legal_imgframe_size_kb", 65536); + Preferences::SetInt("image.mem.max_legal_imgframe_size_kb", 65536); #ifdef MOZ_JXL Preferences::SetBool("image.jxl.enabled", true); #endif diff --git a/image/test/gtest/Common.h b/image/test/gtest/Common.h index bd6ae64a42..1a3792d35c 100644 --- a/image/test/gtest/Common.h +++ b/image/test/gtest/Common.h @@ -59,7 +59,7 @@ struct BGRAColor { } BGRAColor DeviceColor() const { - MOZ_ASSERT(!mPremultiplied); + MOZ_RELEASE_ASSERT(!mPremultiplied); if (msRGB) { gfx::DeviceColor color = gfx::ToDeviceColor( gfx::sRGBColor(float(mRed) / 255.0f, float(mGreen) / 255.0f, @@ -72,8 +72,8 @@ struct BGRAColor { } BGRAColor sRGBColor() const { - MOZ_ASSERT(msRGB); - MOZ_ASSERT(!mPremultiplied); + MOZ_RELEASE_ASSERT(msRGB); + MOZ_RELEASE_ASSERT(!mPremultiplied); return *this; } diff --git a/image/test/gtest/TestDeinterlacingFilter.cpp b/image/test/gtest/TestDeinterlacingFilter.cpp index fc3e6f65bd..d95d4f6954 100644 --- a/image/test/gtest/TestDeinterlacingFilter.cpp +++ b/image/test/gtest/TestDeinterlacingFilter.cpp @@ -186,8 +186,7 @@ TEST_F(ImageDeinterlacingFilter, WritePixelsNonProgressiveOutput51_52) { return AsVariant(BGRAColor::Red().AsPixel()); default: - MOZ_ASSERT_UNREACHABLE("Unexpected row"); - return AsVariant(BGRAColor::Transparent().AsPixel()); + MOZ_CRASH("Unexpected row"); } }); EXPECT_EQ(WriteState::FINISHED, result); @@ -259,8 +258,7 @@ TEST_F(ImageDeinterlacingFilter, WritePixelsOutput20_20) { return AsVariant(BGRAColor::Red().AsPixel()); default: - MOZ_ASSERT_UNREACHABLE("Unexpected row"); - return AsVariant(BGRAColor::Transparent().AsPixel()); + MOZ_CRASH("Unexpected row"); } }); EXPECT_EQ(WriteState::FINISHED, result); @@ -319,8 +317,7 @@ TEST_F(ImageDeinterlacingFilter, WritePixelsOutput7_7) { return AsVariant(BGRAColor::Green().AsPixel()); default: - MOZ_ASSERT_UNREACHABLE("Unexpected row"); - return AsVariant(BGRAColor::Transparent().AsPixel()); + MOZ_CRASH("Unexpected row"); } }); EXPECT_EQ(WriteState::FINISHED, result); @@ -373,8 +370,7 @@ TEST_F(ImageDeinterlacingFilter, WritePixelsOutput3_3) { return AsVariant(BGRAColor::Red().AsPixel()); default: - MOZ_ASSERT_UNREACHABLE("Unexpected row"); - return AsVariant(BGRAColor::Transparent().AsPixel()); + MOZ_CRASH("Unexpected row"); } }); EXPECT_EQ(WriteState::FINISHED, result); diff --git a/image/test/gtest/moz.build b/image/test/gtest/moz.build index 60987b3706..2501e98f60 100644 --- a/image/test/gtest/moz.build +++ b/image/test/gtest/moz.build @@ -12,31 +12,28 @@ UNIFIED_SOURCES = [ "TestAnimationFrameBuffer.cpp", "TestBlendAnimationFilter.cpp", "TestCopyOnWrite.cpp", + "TestDecodersPerf.cpp", + "TestDecodeToSurface.cpp", "TestDeinterlacingFilter.cpp", + "TestDownscalingFilter.cpp", "TestFrameAnimator.cpp", "TestLoader.cpp", + "TestMetadata.cpp", "TestRemoveFrameRectFilter.cpp", + "TestSourceBuffer.cpp", "TestStreamingLexer.cpp", + "TestSurfaceCache.cpp", + "TestSurfacePipeIntegration.cpp", "TestSurfaceSink.cpp", "TestSwizzleFilter.cpp", ] -# skip the test on windows10-aarch64, aarch64 due to 1544961 -if not (CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "aarch64"): +# Bug 1894284 - Fails under TSAN +if not CONFIG["MOZ_TSAN"]: UNIFIED_SOURCES += [ "TestDecoders.cpp", - "TestDecodersPerf.cpp", - "TestDecodeToSurface.cpp", - "TestMetadata.cpp", - "TestSourceBuffer.cpp", - "TestSurfaceCache.cpp", ] -UNIFIED_SOURCES += [ - "TestDownscalingFilter.cpp", - "TestSurfacePipeIntegration.cpp", -] - TEST_HARNESS_FILES.gtest += [ "animated-with-extra-image-sub-blocks.gif", "blend.avif", diff --git a/image/test/reftest/generic/1805599-1-ref.html b/image/test/reftest/generic/1805599-1-ref.html new file mode 100644 index 0000000000..7012356619 --- /dev/null +++ b/image/test/reftest/generic/1805599-1-ref.html @@ -0,0 +1,2 @@ + + diff --git a/image/test/reftest/generic/1805599-1.html b/image/test/reftest/generic/1805599-1.html new file mode 100644 index 0000000000..ee5295dab5 --- /dev/null +++ b/image/test/reftest/generic/1805599-1.html @@ -0,0 +1,34 @@ + + + + + + diff --git a/image/test/reftest/generic/1805599-1.png b/image/test/reftest/generic/1805599-1.png new file mode 100644 index 0000000000..a4fc33db03 Binary files /dev/null and b/image/test/reftest/generic/1805599-1.png differ diff --git a/image/test/reftest/generic/1805599-1.svg b/image/test/reftest/generic/1805599-1.svg new file mode 100644 index 0000000000..efc2fa5617 --- /dev/null +++ b/image/test/reftest/generic/1805599-1.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/image/test/reftest/generic/reftest.list b/image/test/reftest/generic/reftest.list index 5190b52a0e..6729286168 100644 --- a/image/test/reftest/generic/reftest.list +++ b/image/test/reftest/generic/reftest.list @@ -4,3 +4,4 @@ skip-if(Android) != moz-icon-1.html about:blank skip-if(Android) != moz-icon-blank-1-ref.html moz-icon-blank-1-antiref.html skip-if(Android) != moz-icon-blank-1-ref.html moz-icon-blank-1-antiref2.html fuzzy-if(cocoaWidget,44-49,335-348) fuzzy-if(winWidget,64-140,45-191) == moz-icon-blank-1-almostref.html moz-icon-blank-1-ref.html +pref(image.testing.decode-sync.enabled,false) == 1805599-1.html 1805599-1-ref.html -- cgit v1.2.3