Repository navigation
[net 11] [Windows] Fix failing Windows geocoding concurrency test - #37882
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37882Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37882" |
|
Hey there @@Shalini-Ashokan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@Shalini-Ashokan — new AI review results are available based on commit
c2d1095.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ❌ FAILED
The trusted test-verification gate reported a failure. Its detailed display artifact was
missing or contradicted this trusted pipeline verdict, so that agent-writable content was not
used in the review summary.
Inspect the trusted Gate task logs for the failing build or test evidence. This run is not
eligible for approval.
📋 Pre-Flight — Context & Validation
PR #37882 Pre-Flight
Context
- Title:
[WIP][net 11] [Windows] Fix failing Windows geocoding concurrency test - Base:
net11.0; local review merge base9ecc5fc1 - Head under review: local synthetic commit
8e761781c3 - Platform: Windows
- Scope: test-only; one changed file:
src/Core/tests/DeviceTests/Services/EssentialsDIBridgeTests.Windows.cs
PR #37882 repairs ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder, a
Windows Core device test introduced by #36657. The original test stalls the
first MauiApp.Build() while resolving EssentialsCleanup, then assumes
Geocoding.Default has already been assigned to the first app's geocoder.
Current initialization resolves cleanup before making that assignment, so the
barrier does not describe the state the assertion requires.
Existing PR Approach
The PR replaces the cleanup-resolution barrier with a
CallbackPlatformGeocoding barrier in the first geocoder's map-token setter.
That callback occurs after Geocoding.Default has been bridged to the first
geocoder. The PR also removes the now-unused
BlockEssentialsCleanupResolution helper.
Alternative candidates must not repeat this map-token-setter callback
strategy. They may modify only the single changed test file after
EstablishBrokenBaseline.ps1 confirms it in RevertedFiles.
Gate Evidence
The completed gate reported FAILED because the merge-base version of the
changed test passed, whereas the generic test-only gate expected a changed
test to fail without the PR. This is a test-repair PR rather than a new
product-regression test, so that gate result does not itself show that the PR
logic is wrong. The gate must not be rerun or overwritten.
Bounded Validation
Only the detected primary test is in scope; no additional mandatory
regression tests were supplied:
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 `
-Project Core `
-Platform windows `
-Rebuild `
-IncludeClasses "Microsoft.Maui.DeviceTests.Services.EssentialsDIBridgeTests" `
-IncludeMethods "ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder"Each candidate gets one implementation/test pass and, only if needed, one
focused correction/retest. Each attempt must preserve unrelated pre-existing
worktree changes and finish with the exact try-fix restore command.
🔬 Code Review — Deep Analysis
Expert evaluation of the submitted PR
Verdict: The synchronization change is technically sound, with one actionable test-reliability issue that should be incorporated into pr-plus-reviewer.
The PR moves the first-build stall from EssentialsCleanup resolution to the first geocoder's IPlatformGeocoding.MapServiceToken setter. The production ordering in EssentialsMauiAppBuilderExtensions bridges the DI geocoder to Geocoding.Default before applying the explicit map token, so the revised latch reaches the intended state deterministically. The token setter runs outside the global map-token bookkeeping lock, avoiding a deadlock with the concurrent second build. The callback filters unrelated assignments, and the second app's token assertions remain meaningful.
Actionable finding
- Moderate — cleanup can mask the original failure and leak process-static state (
src/Core/tests/DeviceTests/Services/EssentialsDIBridgeTests.Windows.cs:346). If the callback assertion times out or another assertion fails whilefirstBuildis in flight,await firstBuild.WaitAsync(timeout)can throw insidefinally. That exception replaces the original failure and skips disposal plus restoration ofGeocoding.defaultImplementation. The neighboring concurrency test already drains a potentially faulted build withRecord.ExceptionAsync; the same pattern should be used here so restoration always remains reachable.
The expert reviewer emitted this finding to inline-findings.json. No production-code defect, deadlock, or incorrect ownership assertion was identified. The trusted Gate nevertheless failed, so the submitted PR cannot be recommended unchanged on the available evidence.
🛠️ Try-Fix — Analysis & Comparison
PR #37882 — Alternative Try-Fix Aggregate
Candidate 1 — Post-Geocoding DI Barrier (Claude Opus 5)
Result: Blocked before implementation or testing.
Approach
Retarget the merge-base test's DI-resolution barrier from
EssentialsCleanup to IPermissions, the only DI service resolved between
bridging the first geocoder into Geocoding.Default and applying its map
token. Register a blocking IPermissions factory on the first builder and
return null after release; BridgeIfRegistered<T> ignores that null, so
this supplies a barrier without changing the global permissions facade.
The intended sequence is:
- The first build bridges
firstintoGeocoding.Default. - Its
IPermissionsfactory blocks before map-token application. - The test observes
first, builds the second app, and observessecond. - Releasing the factory lets the first build apply its token to its owning
geocoder whileGeocoding.Defaultremainssecond.
Mechanistic Difference
The merge-base approach blocks EssentialsCleanup too early, before the
geocoding bridge. The PR blocks inside first.MapServiceToken and therefore
uses the object and property under test as its synchronization mechanism.
Candidate 1 instead retains a DI-resolution barrier but moves it into the
precise post-bridge/pre-token window using an unrelated, non-mutating service
resolution.
Proposed Diff
The patch was designed but not applied because no baseline allow-list could
be established:
@@ ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder
- var cleanupResolutionEntered = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
- var releaseCleanupResolution = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+ var geocodingBridged = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+ var releaseGeocodingBridged = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var first = new StubPlatformGeocoding();
var second = new StubPlatformGeocoding();
@@
firstBuilder.Services.AddSingleton<IGeocoding>(first);
firstBuilder.ConfigureEssentials(essentials => essentials.UseMapServiceToken(token));
- BlockEssentialsCleanupResolution(
- firstBuilder,
- cleanupResolutionEntered,
- releaseCleanupResolution,
- timeout);
+ firstBuilder.Services.AddSingleton<IPermissions>(_ =>
+ {
+ geocodingBridged.TrySetResult(true);
+ Assert.True(
+ releaseGeocodingBridged.Task.Wait(timeout),
+ "Timed out waiting to release the Essentials permissions resolution.");
+ return null!;
+ });
firstBuild = Task.Run(firstBuilder.Build);
- await cleanupResolutionEntered.Task.WaitAsync(timeout);
+ await geocodingBridged.Task.WaitAsync(timeout);
Assert.Same(first, Geocoding.Default);
@@
- releaseCleanupResolution.TrySetResult(true);
+ releaseGeocodingBridged.TrySetResult(true);
firstApp = await firstBuild.WaitAsync(timeout);
@@ finally
- releaseCleanupResolution.TrySetResult(true);
+ releaseGeocodingBridged.TrySetResult(true);
@@
- static void BlockEssentialsCleanupResolution(...) { ... }Validation and Failure Analysis
The mandatory EstablishBrokenBaseline.ps1 invocation rejected 58
pre-existing unrelated changes under .github/ and eng/.
.github/.baseline-state.json was not created, so there was no
RevertedFiles allow-list and the candidate could not legally edit the test
file. No test was run and no pass is claimed.
The exact scoped command that would have been used was:
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 `
-Project Core `
-Platform windows `
-Rebuild `
-IncludeClasses "Microsoft.Maui.DeviceTests.Services.EssentialsDIBridgeTests" `
-IncludeMethods "ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder"Inline self-review recorded 0 findings because no diff was applied.
The exact restore command ran and reported the expected no-state result:
No baseline state found / Restored False. The PR target file remained
unchanged.
Full narrative:
CustomAgentLogsTmp/PRState/37882/PRAgent/try-fix-1/content.md.
Candidate 2 — Pre-Assignment Token Getter Barrier (GPT-5.6 Sol)
Result: Blocked before implementation or testing.
Approach
Replace the cleanup-resolution barrier with a callback in the first
geocoder's MapServiceToken getter. The product reads this property to
capture rollback state after bridging that geocoder into
Geocoding.Default, but before recording or writing the configured token.
The getter signals and waits, then returns its real backing value. After the
test builds the second app, releasing the getter lets the first build perform
the normal token assignment against its already-captured owner.
Mechanistic Difference
The PR blocks inside the configured-token setter, during the mutation under
assertion. Candidate 2 blocks the preceding rollback-state read, before
bookkeeping or mutation begins; the ordinary setter remains callback-free.
Unlike Candidate 1, it does not add or intercept an unrelated DI service
resolution.
Proposed Diff
The patch was designed but not applied because no baseline allow-list could
be established:
@@ ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder
- var cleanupResolutionEntered = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
- var releaseCleanupResolution = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
- var first = new StubPlatformGeocoding();
+ var firstTokenReadEntered = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+ var releaseFirstTokenRead = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+ var first = new GetterCallbackPlatformGeocoding(() =>
+ {
+ firstTokenReadEntered.TrySetResult(true);
+ Assert.True(
+ releaseFirstTokenRead.Task.Wait(timeout),
+ "Timed out waiting to release the map-token getter.");
+ });
var second = new StubPlatformGeocoding();
@@
firstBuilder.Services.AddSingleton<IGeocoding>(first);
firstBuilder.ConfigureEssentials(essentials => essentials.UseMapServiceToken(token));
- BlockEssentialsCleanupResolution(
- firstBuilder,
- cleanupResolutionEntered,
- releaseCleanupResolution,
- timeout);
firstBuild = Task.Run(firstBuilder.Build);
- await cleanupResolutionEntered.Task.WaitAsync(timeout);
+ await firstTokenReadEntered.Task.WaitAsync(timeout);
Assert.Same(first, Geocoding.Default);
@@
- releaseCleanupResolution.TrySetResult(true);
+ releaseFirstTokenRead.TrySetResult(true);
firstApp = await firstBuild.WaitAsync(timeout);
@@ finally
- releaseCleanupResolution.TrySetResult(true);
+ releaseFirstTokenRead.TrySetResult(true);
@@
- static void BlockEssentialsCleanupResolution(...) { ... }
@@ after StubPlatformGeocoding
+ sealed class GetterCallbackPlatformGeocoding : StubGeocoding, IPlatformGeocoding
+ {
+ readonly Action _onGet;
+ string? _mapServiceToken;
+
+ public GetterCallbackPlatformGeocoding(Action onGet)
+ {
+ _onGet = onGet;
+ }
+
+ public string? MapServiceToken
+ {
+ get
+ {
+ _onGet();
+ return _mapServiceToken;
+ }
+ set => _mapServiceToken = value;
+ }
+ }Validation and Failure Analysis
As in Candidate 1, the mandatory baseline command rejected the same 58
unrelated pre-existing changes and did not create
.github/.baseline-state.json. Candidate 2 therefore made no tracked edit,
ran no test, and claims no pass.
The intended scoped command was:
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 `
-Project Core `
-Platform windows `
-Rebuild `
-IncludeClasses "Microsoft.Maui.DeviceTests.Services.EssentialsDIBridgeTests" `
-IncludeMethods "ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder"Inline self-review recorded 0 findings because no applied diff existed.
The exact restore command ran and reported the expected no-state result:
No baseline state found / Restored False. The PR target file remained
unchanged.
Full narrative:
CustomAgentLogsTmp/PRState/37882/PRAgent/try-fix-2/content.md.
Aggregate Status
Two candidates were generated, satisfying the session cap. Both are
proposed but unvalidated because the mandatory baseline script could not
isolate the PR file in the pre-existing dirty worktree. No production or test
source file was changed, no gate artifact was overwritten, and both attempts
performed the required script-only restore.
📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — remove the WIP/branch-noise prefixes, use the required platform-and-component title shape, and drop the stale description comment that says only main is active even though this PR targets net11.0.
Recommended title
[Windows] Geocoding: Fix concurrency test synchronization
Recommended description
This test case was introduced in PR [#36657](https://github.com/dotnet/maui/pull/36657), and it failed during the PR's CI run.
### Root Cause
The test paused the first `MauiApp.Build()` while resolving `EssentialsCleanup`. However, cleanup is now resolved before the first app's geocoder is assigned to `Geocoding.Default`.
Consequently, the test checked `Geocoding.Default` too early and failed consistently. The failure was caused by the test's assumption about initialization order, not by incorrect map-token ownership in the production code.
### Description of Change
The test now pauses when the map-service token is being assigned to the first app's geocoder. At this point, the geocoder has already been assigned to `Geocoding.Default`.
This directly synchronizes on the behavior under test and follows the callback-based approach already used by a neighboring map-token concurrency [test](https://github.com/dotnet/maui/blob/ec79089f659b4964710d59d4dc4a4e5fb59c7091/src/Core/tests/DeviceTests/Services/EssentialsDIBridgeTests.Windows.cs#L358).
The obsolete `EssentialsCleanup` synchronization helper was also removed because it was used only by this test.
### Test case
Device Test
`ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder`
### Snapshot
| Before | After |
|---|---|
| <img width="1958" height="984" alt="image" src="https://github.com/user-attachments/assets/111799b5-1d56-48a8-8dfe-3d9f0f603b5a" /> | <img width="1958" height="984" alt="After" src="https://github.com/user-attachments/assets/eb1039dc-7102-447f-9910-699abcdb2851" /> |
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Winner: pr-plus-reviewer
The submitted synchronization strategy is correct, but the expert reviewer identified a concrete failure-cleanup weakness on the modified path. pr-plus-reviewer retains the correct map-token-setter barrier, prevents a faulted in-flight build from masking the original assertion failure or skipping process-static restoration, and passed the required Windows device-test command. Because the winning cleanup change is not present in the submitted PR HEAD, the PR should be updated before approval.
Candidate comparison
| Rank | Candidate | Implementation | Validation | Assessment |
|---|---|---|---|---|
| 1 | pr-plus-reviewer |
Submitted fix plus guarded draining of firstBuild in cleanup |
PASS — required command exited 0; scoped method passed and all 21 executed class tests passed | Best combination of correct synchronization, failure isolation, and empirical evidence |
| 2 | pr |
Blocks in the owning geocoder's map-token setter after Geocoding.Default is bridged |
Trusted Gate FAILED because the merge-base test also passed; no product regression was demonstrated | Core approach is correct, but a faulted build can throw from finally, mask the original failure, and skip static-state restoration |
| 3 | try-fix-2 |
Proposed pre-assignment MapServiceToken getter barrier |
BLOCKED / not run; no candidate diff was applied | Mechanistically relevant to token ownership, but adds a new callback geocoder type and has no executed evidence |
| 4 | try-fix-1 |
Proposed post-geocoding IPermissions DI-resolution barrier |
BLOCKED / not run; no candidate diff was applied | Correctly targets the ordering window in theory, but couples the test to an unrelated service-resolution sequence and has no executed evidence |
Expert review
The production sequence bridges the DI IGeocoding instance before applying an explicit map token, and token reconciliation invokes the setter outside the global bookkeeping lock. The PR's revised latch therefore observes the intended ownership state without deadlocking the second build. The sole expert finding is at src/Core/tests/DeviceTests/Services/EssentialsDIBridgeTests.Windows.cs:346: an unguarded cleanup await can replace the original failure and prevent restoration of Geocoding.defaultImplementation.
pr-plus-reviewer resolves that finding with the neighboring test's established Record.ExceptionAsync pattern while retaining a successfully completed MauiApp for disposal. Its reviewer diff passed git diff --check, and its validation artifacts are rooted in the mandated sandbox.
Gate interpretation
The trusted Gate result remains failed and was not rerun. Its failure means the merge-base version of this existing test passed when the generic test-only Gate expected it to fail. That limits approval of the raw PR, but it does not contradict the root cause: this PR repairs stale test synchronization rather than adding a regression test for faulty production behavior.
The two STEP 5a candidates are ranked below the passing candidate because both were blocked before implementation and testing. No unvalidated proposal outranks an implemented candidate with a passing required regression command.
📱 UI Tests — Button,Label,Layout
Detected UI test categories: Button,Label,Layout
[!WARNING]
No UI test results were produced for the detected categories. The platform-pool run
returned no results — most often because the PR build failed (see the Gate section) or
the deep UI test stage was skipped. Fix the build/gate issues and push again; the review
re-runs on new commits (a maintainer can also re-run it).
🧭 Next Steps — reviewer changes required
The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.
Why: The submitted setter-based synchronization is correct, and pr-plus-reviewer adds the expert-recommended cleanup guard so a faulted build cannot mask the original failure or skip static-state restoration. It is the only refined candidate that was implemented and passed the required Windows device-test validation.
Address the actionable findings in this review before merging.
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The updated test cleanup path can throw in finally and mask the original failure, reducing diagnostic quality and potentially increasing flakiness.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates a Windows device-test in EssentialsDIBridgeTests.Windows.cs to remove a brittle synchronization point and instead stall the first concurrent MauiApp.Build() at the moment the map-service token is assigned to the first app’s IPlatformGeocoding, aligning the test with the actual initialization order introduced by the Essentials DI bridge changes.
Changes:
- Replace the prior “pause during EssentialsCleanup resolution” synchronization with a callback-based stall on the
MapServiceTokensetter. - Remove the now-unused
BlockEssentialsCleanupResolutionhelper that rewired service registration to inject a blocking factory.
File summaries
| File | Description |
|---|---|
| src/Core/tests/DeviceTests/Services/EssentialsDIBridgeTests.Windows.cs | Reworks the concurrency test synchronization to stall on map-token assignment and removes the obsolete EssentialsCleanup-based helper. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
| releaseFirstTokenSetter.TrySetResult(true); | ||
| if (firstBuild is not null && firstApp is null) | ||
| firstApp = await firstBuild.WaitAsync(timeout); | ||
|
|
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!
This test case was introduced in PR #36657, and it failed during the PR’s CI run.
Root Cause
The test paused the first
MauiApp.Build()while resolvingEssentialsCleanup. However, cleanup is now resolved before the first app's geocoder is assigned toGeocoding.Default.Consequently, the test checked
Geocoding.Defaulttoo early and failed consistently. The failure was caused by the test's assumption about initialization order, not by incorrect map-token ownership in the production code.Description of Change
The test now pauses when the map-service token is being assigned to the first app's geocoder. At this point, the geocoder has already been assigned to
Geocoding.Default.This directly synchronizes on the behavior under test and follows the callback-based approach already used by a neighboring map-token concurrency test.
The obsolete
EssentialsCleanupsynchronization helper was also removed because it was used only by this test.Test case
Device Test
ConcurrentBuildAppliesMapServiceTokenToOwningGeocoder
Snapshot