Repository navigation
[Resizetizer] Retry splash cleanup deletes while a file is briefly locked - #40351
Conversation
…cked Windows can refuse to delete a just-written splash image while another process (antivirus, indexer) briefly holds it open. GenerateSplashAssetCatalog, GenerateSplashStoryboard and GenerateSplashAndroidResources deleted their previous outputs without retrying, failing the task with 'The process cannot access the file ... because it is being used by another process'. Apply the existing image-write retry policy (ERROR_SHARING_VIOLATION / ERROR_ACCESS_DENIED, DOTNET_ANDROID_FILE_WRITE_RETRY_*) to these cleanup deletes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/rebase |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
…tries Expose the retry loop with an explicit attempt count and delay so tests can pin its exception filter without waiting on the default 10 x 1 s policy: - an I/O error that is not a lock propagates after a single attempt - a lock that outlasts every retry propagates after attempts + 1 tries Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
/rebase |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit d90bbd4.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis🧪 CI Analysis — click to expand📊 maui-pr
🧪 maui-pr-devicetests
🧪 maui-pr-uitestsNo failures found. 🧭 Follow-up — actions and refreshNext action: Restore missing diagnostics/completion evidence; compare the exact device-test variants on the target branch.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Attribution for the tests-failure analysis of
|
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit d90bbd4.
…cked (#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating #40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…40391) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change CI hardening only. No product, test, or pipeline YAML changes. **Symptom.** Candidate UI build [1687815](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687815) (#40116), job *Controls Lifecycle,ManualReview,Maps* on Mac, failed in **Install Appium** before any test ran. All 5 RetryHelper attempts failed. Log 4334 shows this chain: 1. `npm list -g appium` → not installed. 2. The normal `npm i --location=global appium@2.17.1` fails with a transient `ERR_SOCKET_TIMEOUT`. 3. `InstallAppium` falls back to `sudo -E npm i --location=global appium@2.17.1`, which **succeeds**. 4. `appium driver install uiautomator2@4.2.1` (runs as the agent user) fails with `EACCES: mkdir '/Users/cloudtest/.npm/_cacache/index-v5/…'`. npm explains: *"Your cache folder contains root-owned files … sudo chown -R 501:20 /Users/cloudtest/.npm"*. 5. Retries 2–5 fail on the same root-owned cache (`EACCES`/`EEXIST`), then on `ENOTEMPTY` debris in `.appium/node_modules/appium`. **Root cause.** `sudo -E` preserves `HOME`, so the elevated npm uses and populates the user's `~/.npm/_cacache` as root. Every later non-root npm call on the agent then fails. A single network blip becomes a job failure that retries cannot fix. **Same signature elsewhere (UI pipeline 313, builds since 11-13):** | Build | Context | Agent / log | Notes | | --- | --- | --- | --- | | 1687815 | candidate | Mac, AcesShared 107, log 4334 | This failure. | | 1686824 | PR #40351 | Mac, AcesShared 90, log 3817 | Identical chain. | | 1685341 | main | 13 Linux jobs | Network outage; the sudo fallback then hit `EACCES` on `/home/cloudtest/.npm/_cacache`. | The next job on AcesShared 107 (log 5398) passed, so the damage is per job, not per machine. **Fix.** In `src/Provisioning/Provisioning.csproj`, the macOS/Linux `ElevatedNpmCommand` now passes `--cache "<temp>/maui-elevated-npm-cache"`. npm keeps its logs and update-notifier state under the cache directory too, so the elevated install no longer writes anything into `~/.npm`. The normal (non-elevated) path, the Windows elevation command, versions, timeouts, and retry budgets are unchanged. **Validation.** Real root was unavailable locally, so I emulated it: - Node/npm matched CI: Node 20.3.1 / npm 9.6.7, the UseNode version in `ui-tests-steps.yml`. - `HOME`, `APPIUM_HOME`, and the npm global prefix were isolated. - A `sudo` shim runs the command, then removes write permission from every path that command **created**. This matches what a non-root user can do with root-owned 755/644 entries. - An `npm` shim fails the first non-elevated `npm i --location=global appium@…` with `ERR_SOCKET_TIMEOUT`. Each state ran the real target, `dotnet build ./src/Provisioning/Provisioning.csproj -t:ProvisionAppium -p:SkipAppiumDoctor=true`, repeated up to CI's 5 attempts: | State | Result | | --- | --- | | Baseline (`origin/net11`) | **Red 4/4**: `appium driver install uiautomator2@4.2.1` fails with npm's "cache folder contains root-owned files" `EACCES`; 3,612 non-writable entries left in `~/.npm`. | | Fix | **Green on attempt 1**: uiautomator2 4.2.1, mac2 1.20.3, and xcuitest 7.32.0 installed; 0 root-created paths under `HOME` or `APPIUM_HOME`. | | Fix reverted | **Red 5/5**, same `EACCES`. | | Fix restored | **Green on attempt 1**. | | Control (no network failure) | **Green**; the elevated command is not invoked. | In the emulation, the elevated install created nothing under `APPIUM_HOME`, so isolating the npm cache is enough. Other checks: `xmllint --noout` on the csproj and `git diff --check` both pass. Real CI on this PR exercises the normal path; the elevated path only runs after a network failure. I found no open or recently merged PR that changes the elevated npm install. `Provisioning.csproj` is byte-identical on `net11`, `main`, `inflight/current`, and `candidate/11.0.1xx-sr2`. ### Issues Fixed No tracking issue. Found while analysing candidate PR #40116 CI (UI build 1687815). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cked (#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating #40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cked (#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating #40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cked (#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating #40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cked (#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating #40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cked (#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating #40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cked (dotnet#40351) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). This is a repair for the SR2 candidate (dotnet#40116), so it targets `candidate/11.0.1xx-sr2` as assigned. For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change **Failure.** A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build [1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611) (run 47069628, result 106302, Helix job `14b1fbed-f357-4884-a932-9373167fdc39`): - Test: `GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light")`. - Error: `System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process`. - Stack: `Directory.Delete` → `GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()` (line 35). The task regenerates its splash outputs by deleting the previous `Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned `false`. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder. `SkiaSharpTools.Save` already retries image **writes** when Windows reports a sharing or access violation. It reads its policy from `DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` / `DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at 1000 ms. The **deletes** in the splash tasks had no such protection. **Fix** - `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries` reuse that same retry policy. They retry only an `IOException` / `UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION` or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged. - `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and `GenerateSplashStoryboard` use these helpers for their cleanup `File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise unchanged. - `SkiaSharpTools`' two error-code constants change from `private` to `internal` so the helpers can share them. The retry loop also has an `internal` overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes. **Test.** The new `[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage` (in `GenerateSplashAssetCatalogTests`) does the following: 1. Generates the asset catalog. 2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`, which reproduces the sharing violation. 3. Releases the file after 1.5 s. 4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size. A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed. Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked` pin the exception filter, using 3 attempts and no delay: - `PropagatesOtherIOErrorsWithoutRetrying`: a `DirectoryNotFoundException`, which is an `IOException` but not a lock, propagates unchanged after exactly 1 call. - `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1). ### Validation **Causal check on Helix `Windows.10.Amd64.Open`** (full Resizetizer.UnitTests, Debug, submitted locally): - The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored. - A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs. | Variant | Helix job | Machine | Product / test DLL sha256 | Result | |---|---|---|---|---| | Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` | a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (`IOException … being used by another process` at `CleanImageSet()` line 289) | | Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | | Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 | `97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test `IOException` (798 total, 1 failed) | | Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 | `b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) | The only skips in every run were the existing `ValidFilenames_Unix` and `InvalidFilenames_Unix` tests. **Local checks** - macOS, head `d90bbd4605`: `dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj` **passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test. - Mutation check of the helper tests (`--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`): - With the lock filter `IsFileLocked(ex)` removed, `PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call, got 4). - With the retry bound changed from `attempt < attempts` to `attempt <= attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4 calls, got 5). - With the code restored, both **passed**. - `dotnet format whitespace --folder --verify-no-changes --include <7 changed files>`: **passed**. `dotnet format whitespace --verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the follow-up commit also **passed**. **Not shown here:** the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead. ### Issues Fixed Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset` cleanup failure (`IOException` from `CleanImageSet`) found while validating dotnet#40116. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewThis is a repair for the SR2 candidate (#40116), so it targets
candidate/11.0.1xx-sr2as assigned.For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
Failure. A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build 1686611 (run 47069628, result 106302, Helix job
14b1fbed-f357-4884-a932-9373167fdc39):GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light").System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process.Directory.Delete→GenerateSplashAssetCatalog.CleanImageSet()(line 289) →Execute()(line 35).The task regenerates its splash outputs by deleting the previous
Assets.xcassets/MauiSplashImage.imagesetfolder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returnedfalse. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder.SkiaSharpTools.Savealready retries image writes when Windows reports a sharing or access violation. It reads its policy fromDOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS/DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS, defaulting to 10 attempts at 1000 ms. The deletes in the splash tasks had no such protection.Fix
Utils.DeleteFileWithRetries/Utils.DeleteDirectoryWithRetriesreuse that same retry policy. They retry only anIOException/UnauthorizedAccessExceptionwhose HRESULT isERROR_SHARING_VIOLATIONorERROR_ACCESS_DENIED, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged.GenerateSplashAssetCatalog,GenerateSplashAndroidResourcesandGenerateSplashStoryboarduse these helpers for their cleanupFile.Delete/Directory.Deletecalls. Their behaviour is otherwise unchanged.SkiaSharpTools' two error-code constants change fromprivatetointernalso the helpers can share them. The retry loop also has aninternaloverload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes.Test. The new
[WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage(inGenerateSplashAssetCatalogTests) does the following:MauiSplashImage.pngwithFileShare.Read, which reproduces the sharing violation.A new
WindowsFactattribute, which mirrors the existingUnixTheory, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed.Two cross-platform helper tests in
UtilsTests.RetryWhileFileIsLockedpin the exception filter, using 3 attempts and no delay:PropagatesOtherIOErrorsWithoutRetrying: aDirectoryNotFoundException, which is anIOExceptionbut not a lock, propagates unchanged after exactly 1 call.PropagatesLockThatOutlastsAllRetries: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1).Validation
Causal check on Helix
Windows.10.Amd64.Open(full Resizetizer.UnitTests, Debug, submitted locally):cfa5da13-137c-44f9-ba16-e19ca0f381da97fde500…/2dc3f20d…IOException … being used by another processatCleanImageSet()line 289)55936228-b40c-4490-92a6-83e763e844d1b9cc28ae…/3bacf8d6…9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc97fde500…/2dc3f20d…IOException(798 total, 1 failed)2680c012-48d5-4866-bbed-5f8f1026a0b9b9cc28ae…/3bacf8d6…The only skips in every run were the existing
ValidFilenames_UnixandInvalidFilenames_Unixtests.Local checks
d90bbd4605:dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csprojpassed: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test.--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"):IsFileLocked(ex)removed,PropagatesOtherIOErrorsWithoutRetryingfailed (expected 1 call, got 4).attempt < attemptstoattempt <= attempts,PropagatesLockThatOutlastsAllRetriesfailed (expected 4 calls, got 5).dotnet format whitespace --folder --verify-no-changes --include <7 changed files>: passed.dotnet format whitespace --verify-no-changesonUtils.csandUtilsTests.csafter the follow-up commit also passed.Not shown here: the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead.
Issues Fixed
Fixes the Windows Resizetizer
ResizeQualityMetadataAffectsImageAssetcleanup failure (IOExceptionfromCleanImageSet) found while validating #40116.