From 83c3a61e3f14a1743dd1d50f9a382f54343510e6 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Tue, 24 Jan 2023 19:19:47 -0800 Subject: [PATCH] Only emit image painting events in debug & profile modes. (#118872) * Only emit image painting events in debug & profile modes. These events were being emitted in release mode, which was showing up in the profiler for my app as taking up a noticeable amount of build time (still well within the frame budget, but this code was near the top of the list). * Review comment --- packages/flutter/lib/src/painting/decoration_image.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/painting/decoration_image.dart b/packages/flutter/lib/src/painting/decoration_image.dart index d94741e33b..92cdecc0d2 100644 --- a/packages/flutter/lib/src/painting/decoration_image.dart +++ b/packages/flutter/lib/src/painting/decoration_image.dart @@ -599,7 +599,7 @@ void paintImage({ return true; }()); // Avoid emitting events that are the same as those emitted in the last frame. - if (!_lastFrameImageSizeInfo.contains(sizeInfo)) { + if (!kReleaseMode && !_lastFrameImageSizeInfo.contains(sizeInfo)) { final ImageSizeInfo? existingSizeInfo = _pendingImageSizeInfo[sizeInfo.source]; if (existingSizeInfo == null || existingSizeInfo.displaySizeInBytes < sizeInfo.displaySizeInBytes) { _pendingImageSizeInfo[sizeInfo.source!] = sizeInfo;