Correct backoff retry time cap unit and add regression tests#187250
Conversation
…ests Fix a critical unit mismatch bug in "AndroidGradleBuilder._runGradleTask" where "kMaxRetryTime.inMicroseconds" (10,000,000) was mistakenly used instead of "inMilliseconds" (10,000) to cap the exponential backoff delay duration (which is calculated in milliseconds). This error allowed the backoff delay time to scale up uncapped to 2.77 hours instead of properly capping it at 10 seconds, significantly hanging failed/unstable builds. Added a robust unit test using "FakeAsync" to simulate 8 failing build retries instantaneously, verifying that wait times double correctly (100ms -> 200ms -> 400ms -> 800ms -> 1600ms -> 3200ms -> 6400ms) and cap cleanly at exactly 10000ms (10s) on the 8th retry. Additionally, added a safeguard to cap the exponent in the pow calculation at 7, preventing potential integer overflow on high retry counts (when maxRetries is null). TAG=agy CONV=2896dcb0-c691-411e-a016-bfac6cf044e3
There was a problem hiding this comment.
Code Review
This pull request modifies the Gradle build retry logic in packages/flutter_tools/lib/src/android/gradle.dart by capping the exponential backoff exponent to 7 and correcting the maximum retry time unit from microseconds to milliseconds. A review comment suggests simplifying the power-of-two calculation by using the bitwise left shift operator instead of pow.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
reidbaker
left a comment
There was a problem hiding this comment.
1 second = 1,000 milliseconds (ms)
1 second = 1,000,000 microseconds (μs)
Wait time was already a min. This pr description makes it seem like we would eventually wait for hours instead of seconds. I dont follow how that can happpen.
The calculation is done in microseconds and then fed to the line of code: which is in milliseconds. So, wait time would be 10,000,000 / 1,000 = 10,000 seconds, or 2.77 hours |
Roll Flutter from b7cb925419e6 to 5827d5fd2b8d (35 revisions) flutter/flutter@b7cb925...5827d5f 2026-06-15 engine-flutter-autoroll@skia.org Roll Skia from 7128af60575a to c8d9f80f13e4 (1 revision) (flutter/flutter#188015) 2026-06-15 jason-simmons@users.noreply.github.com In the APNG decoder, validate the chunk data length before calling GetChunkSize to avoid potential overflow in the chunk size calculation (flutter/flutter#187949) 2026-06-15 engine-flutter-autoroll@skia.org Roll Skia from 6b4ac3bfb39d to 7128af60575a (1 revision) (flutter/flutter#188011) 2026-06-15 engine-flutter-autoroll@skia.org Roll Skia from 0a3b8549cbf0 to 6b4ac3bfb39d (7 revisions) (flutter/flutter#188007) 2026-06-15 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[a11y] Map some framework semantics roles to android classes. (#185217)" (flutter/flutter#188008) 2026-06-15 chris@bracken.jp [ios] Filter UIScene events to those relating to Flutter VC scene (flutter/flutter#187987) 2026-06-15 jhy03261997@gmail.com [a11y] Map some framework semantics roles to android classes. (flutter/flutter#185217) 2026-06-15 engine-flutter-autoroll@skia.org Roll Skia from f46928e7f50c to 0a3b8549cbf0 (1 revision) (flutter/flutter#188004) 2026-06-14 stuartmorgan@google.com Rework docs for flutter/packages changelogs (flutter/flutter#187666) 2026-06-14 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nvzMQAmuRSzo7-wAP... to TbB86Po_HDe1dvXvT... (flutter/flutter#187997) 2026-06-14 engine-flutter-autoroll@skia.org Roll Skia from 4e2c9b5e4dad to f46928e7f50c (1 revision) (flutter/flutter#187996) 2026-06-14 engine-flutter-autoroll@skia.org Roll Skia from c52667607242 to 4e2c9b5e4dad (1 revision) (flutter/flutter#187990) 2026-06-14 737941+loic-sharma@users.noreply.github.com Improve RenderTargetCache docs (flutter/flutter#187893) 2026-06-13 brackenavaron@gmail.com [Test cross_imports] Check cross imports in flutter_test/** (flutter/flutter#187587) 2026-06-13 matt.kosarek@canonical.com Fixing corrupted window size OnEmptyFrameGenerated due to transpsed width/height (flutter/flutter#187954) 2026-06-13 engine-flutter-autoroll@skia.org Roll Skia from 42355271a335 to c52667607242 (2 revisions) (flutter/flutter#187979) 2026-06-13 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from A3eaUn9mQ_EkSNxVI... to nvzMQAmuRSzo7-wAP... (flutter/flutter#187975) 2026-06-13 engine-flutter-autoroll@skia.org Roll Skia from 9ef46390c2d1 to 42355271a335 (1 revision) (flutter/flutter#187974) 2026-06-13 bdero@google.com [Flutter GPU] Make ShaderLibrary.fromAsset asynchronous (flutter/flutter#187716) 2026-06-13 engine-flutter-autoroll@skia.org Roll Skia from 8c89bf2b0ee3 to 9ef46390c2d1 (6 revisions) (flutter/flutter#187968) 2026-06-12 bdero@google.com [Flutter GPU] Add surface API for framework presentation (flutter/flutter#187358) 2026-06-12 bkonyi@google.com [gen_l10n] Exclude inherited keys from untranslated-messages-file (flutter/flutter#187950) 2026-06-12 31859944+LongCatIsLooong@users.noreply.github.com Update `MediaQueryData` docs for devicePixelRatio overriding (flutter/flutter#187542) 2026-06-12 bdero@google.com [Impeller] Fix dirty-range race in DeviceBufferGLES uploads (flutter/flutter#187932) 2026-06-12 pascal@phntm.xyz Compare isModifiedAfter against the given time (flutter/flutter#187727) 2026-06-12 planetmarshall@users.noreply.github.com Enable unit tests for compilation of compute shaders on non-metal backends (flutter/flutter#179683) 2026-06-12 matt.boetger@gmail.com [flutter_tools] Add doctor validator warning for multiple adb installations (flutter/flutter#186031) 2026-06-12 matt.boetger@gmail.com Optimize SHA hash calculation of generated APK (flutter/flutter#187184) 2026-06-12 mu7ammadkamel@hotmail.com Scope widget inspector overlay to the selected widget's modal route (flutter/flutter#186784) 2026-06-12 30870216+gaaclarke@users.noreply.github.com Switches Windows to OpenGLESSDF (flutter/flutter#187877) 2026-06-12 matt.boetger@gmail.com [integration_test] Update README to support modern Kotlin-based setups by default (flutter/flutter#186080) 2026-06-12 jason-simmons@users.noreply.github.com Convert the PNG signature constant in APNGImageGenerator to a std::array and use it in the APNG tests (flutter/flutter#187930) 2026-06-12 matt.boetger@gmail.com Correct backoff retry time cap unit and add regression tests (flutter/flutter#187250) 2026-06-12 chingjun@google.com Fix std::vector out-of-bounds access in Flutter Android JNI and Delegate (flutter/flutter#187218) 2026-06-12 matt.boetger@gmail.com [Android] Adding 30-second timeouts to adb stopApp and uninstallApp (flutter/flutter#187876) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 ...
…#187250) Fix a critical unit mismatch bug in "AndroidGradleBuilder._runGradleTask" where "kMaxRetryTime.inMicroseconds" (10,000,000) was mistakenly used instead of "inMilliseconds" (10,000) to cap the exponential backoff delay duration (which is calculated in milliseconds). This error allowed the backoff delay time to scale up uncapped to 2.77 hours instead of properly capping it at 10 seconds, significantly hanging failed/unstable builds. Added a robust unit test using "FakeAsync" to simulate 8 failing build retries instantaneously, verifying that wait times double correctly (100ms -> 200ms -> 400ms -> 800ms -> 1600ms -> 3200ms -> 6400ms) and cap cleanly at exactly 10000ms (10s) on the 8th retry. Additionally, added a safeguard to cap the exponent in the pow calculation at 7, preventing potential integer overflow on high retry counts (when maxRetries is null). Fixes: flutter#83971 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Fix a critical unit mismatch bug in "AndroidGradleBuilder._runGradleTask" where "kMaxRetryTime.inMicroseconds" (10,000,000) was mistakenly used instead of "inMilliseconds" (10,000) to cap the exponential backoff delay duration (which is calculated in milliseconds).
This error allowed the backoff delay time to scale up uncapped to 2.77 hours instead of properly capping it at 10 seconds, significantly hanging failed/unstable builds.
Added a robust unit test using "FakeAsync" to simulate 8 failing build retries instantaneously, verifying that wait times double correctly (100ms -> 200ms -> 400ms -> 800ms -> 1600ms -> 3200ms -> 6400ms) and cap cleanly at exactly 10000ms (10s) on the 8th retry.
Additionally, added a safeguard to cap the exponent in the pow calculation at 7, preventing potential integer overflow on high retry counts (when maxRetries is null).
Fixes: #83971
Pre-launch Checklist
///).