increase the value of debugImageOverheadAllowance from 104 bytes to 128kb (#73720)
diff --git a/packages/flutter/lib/src/painting/debug.dart b/packages/flutter/lib/src/painting/debug.dart index 54692f7..f1a42f3 100644 --- a/packages/flutter/lib/src/painting/debug.dart +++ b/packages/flutter/lib/src/painting/debug.dart
@@ -157,11 +157,13 @@ /// This has no effect unless asserts are enabled. bool debugInvertOversizedImages = false; +const int _imageOverheadAllowanceDefault = 128 * 1024; + /// The number of bytes an image must use before it triggers inversion when /// [debugInvertOversizedImages] is true. /// -/// Default is 1024 (1kb). -int debugImageOverheadAllowance = 1024; +/// Default is 128kb. +int debugImageOverheadAllowance = _imageOverheadAllowanceDefault; /// Returns true if none of the painting library debug variables have been changed. /// @@ -180,7 +182,7 @@ debugNetworkImageHttpClientProvider != null || debugOnPaintImage != null || debugInvertOversizedImages == true || - debugImageOverheadAllowance != 1024) { + debugImageOverheadAllowance != _imageOverheadAllowanceDefault) { throw FlutterError(reason); } return true;
diff --git a/packages/flutter/test/painting/paint_image_test.dart b/packages/flutter/test/painting/paint_image_test.dart index 1f52caa..6f47cfc 100644 --- a/packages/flutter/test/painting/paint_image_test.dart +++ b/packages/flutter/test/painting/paint_image_test.dart
@@ -20,6 +20,7 @@ void main() { late ui.Image image300x300; late ui.Image image300x200; + setUpAll(() async { image300x300 = await createTestImage(width: 300, height: 300, cache: false); image300x200 = await createTestImage(width: 300, height: 200, cache: false); @@ -108,6 +109,36 @@ FlutterError.onError = oldFlutterError; }); + test('debugInvertOversizedImages smaller than overhead allowance', () async { + debugInvertOversizedImages = true; + final FlutterExceptionHandler? oldFlutterError = FlutterError.onError; + + final List<String> messages = <String>[]; + FlutterError.onError = (FlutterErrorDetails details) { + messages.add(details.exceptionAsString()); + }; + + try { + // Create a 290x290 sized image, which is ~24kb less than the allocated size, + // and below the default debugImageOverheadAllowance size of 128kb. + const Rect rect = Rect.fromLTWH(50.0, 50.0, 290.0, 290.0); + final TestCanvas canvas = TestCanvas(); + + paintImage( + canvas: canvas, + rect: rect, + image: image300x300, + debugImageLabel: 'TestImage', + fit: BoxFit.fill, + ); + + expect(messages, isEmpty); + } finally { + debugInvertOversizedImages = false; + FlutterError.onError = oldFlutterError; + } + }); + test('centerSlice with scale ≠ 1', () async { final TestCanvas canvas = TestCanvas(); paintImage(