Skip to content

Fix Android shared image tinting and stabilize device tests - #38713

Closed
kubaflo wants to merge 11 commits into
mainfrom
kubaflo-android-ios-test-failures
Closed

kubaflo wants to merge 11 commits into
mainfrom
kubaflo-android-ios-test-failures

Conversation

@kubaflo

@kubaflo kubaflo commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

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!

Summary

Fix Android shared-drawable tinting, device-test lifecycle assumptions, and Windows Helix SDK selection/result integrity. This started from failures in main-targeting device build 1603846, compared with passing SR11 build 1602667, and includes subsequent failures observed while validating this PR. No global timeout, test skip, retry, or weakened assertion is added.

  • Android image rendering - reproduced product bug: SwipeItemMenuItemHandler applied a color filter to a resource drawable without calling Mutate(). Its shared state could then make a separately loaded red.png render black. Call Mutate() before applying icon styling. Add SwipeItemIconTintDoesNotAffectSharedImageSource, which creates a tinted SwipeItem and renders a separately loaded copy onto a canvas, requiring the original red pixels. It fails with an all-black image before the product fix and passes afterward. The SwipeItem still receives its intended tint. Remove the earlier window/layout-readiness workaround: build 1605367 disproved it, and the original ImageWithUndefinedSizeAndWithBackgroundSetRenders is restored unchanged from main.
  • Apple HybridWebView leak check: Replace the fixed delay before handler creation with the existing bounded page-readiness helper after native creation. Preserve handler disconnection and all three weak-reference assertions; do not dispose the native object to force collection. Windows keeps its WebView2 readiness API.
  • HybridWebView functional-test cleanup: After AttachAndRun detaches the test-owned view, disconnect its handler on non-Windows platforms and destroy/dispose the Android native WebView in a UI-thread finally. Windows already disconnects and closes the browser when its test host closes the window and must not be disconnected again. This applies to the functional-test helper, not the memory-leak assertion. Readiness timeouts now report URL, document readiness, bridge presence, sentinel presence, and body text. The 25-second bound and assertions are unchanged. Missing cleanup was found while investigating a Mono timeout; a direct causal reproduction of that timeout was not obtained.
  • Nested tab navigation: Give only this ten-animation scenario a 30-second timeout instead of the helper's default 15 seconds. Preserve all four Android parameter combinations and all navigation/loaded waits.
  • Android Essentials lifecycle assertions: Run registration, simulated callbacks, exact assertions, and cleanup in one synchronous main-thread dispatch. The old test counted real application lifecycle events concurrently with its simulated callback; logs showed the previous recreation test's activity still being destroyed during the assertion. Dispose both test-created managers in finally. Preserve the one-event assertion and distinct-listener simulation that detects duplicate registrations.
  • Windows SDK payload: Incorporate the full fix and regression checks from Fix Windows device-test Helix SDK version resolution #38692 (cherry-picked commit cf4074a85). Windows must use the full MicrosoftNETSdkPackageVersion, not the shortened NETCoreSdkVersion, to download servicing SDKs. Preserve explicit overrides and XHarness SDK selection on other platforms.
  • Windows Map test readiness: NavigationCompleted is earlier than WinUI's asynchronous native layer/pin initialization. The unpackaged Map process in build 1605524 crashed with stowed HRESULT 0x8007139f; matching native symbols point to Map layer/element operations calling WebView2 ExecuteScriptAsync. Wait for the browser's layer creation and pin script to execute before unloading the control, including after reattaching it. Keep the existing 15-second bound and every native-layer/pin assertion. Do not change MapHandler ownership, clear native layers, or close the Map-owned WebView2. This timing correction still requires current-head Windows CI; no local Windows reproduction is claimed.
  • Windows result integrity: Propagate unpackaged app exit codes, and retain the packaged process handle so its exit code can also be propagated. Replace warning-only XML merging with a shared helper that rejects empty/malformed results, missing assembly/count data, inconsistent declared/actual test counts, failed tests, and assembly errors. Preserve readable results for diagnosis while returning failure for an incomplete run. The helper is included in the existing eng correlation payload.

Current verification status

Head 065f4c982b requires full device CI. This PR is not yet verified green across all device suites. Completion requires all seven Helix jobs and all 46 actual suite result sets, including complete Windows category results in both packaging modes. Aggregate pipeline success is insufficient.

Build 1605524 on b90966c8ab reported success, but inspecting all seven Helix jobs and all 46 aggregate XML files found a hidden Windows unpackaged Map crash. Its zero-byte Map XML was omitted with only a warning. Controls reported 866 total / 835 passed / 31 skipped instead of the packaged run's 868 total / 837 passed / 31 skipped. Two Map tests were missing and a native crash dump was uploaded. This is an incomplete run, not a pass; the latest commit addresses both the readiness race and the runner's false-green behavior.

The other 45 suite result sets were complete with zero failures. Both Android runtimes had Controls 994 total / 982 passed / 12 existing skips, and both the new tint regression and restored original image test explicitly passed. Android CoreCLR's local GC failures did not recur in this CI run. All iOS 18.1/26 and MacCatalyst 15/26 suites had complete results; the earlier missing MacCatalyst Core XML did not recur. The 90 Windows HybridWebView teardown failures were gone in both packaging modes, but that does not excuse the missing unpackaged Map results.

Earlier failures are retained here rather than hidden by later passes:

Build Actual device-test evidence
1605367 Original CoreCLR image failure recurred: Controls 980 passed, 1 failed, 12 existing skips, with a black rather than red image. Canceled on the follow-up push; outstanding results were not verified. MacCatalyst 15 Core exited zero without XML and was explicitly unverified.
1605221 All 46 suite XML files inspected. Android, iOS, MacCatalyst, and non-Controls Windows suites passed. Windows Controls had 90 distinct teardown failures repeated in packaged/unpackaged modes.
1605067 All suites passed except one Mono HybridWebView page-readiness timeout. Both corrected Essentials tests passed on Mono/CoreCLR.
1604353 Android Controls and Apple suites passed, but Essentials failed its event count and Windows failed SDK resolution.
1604297 The initial image-test revision still failed.

The 1605221 Windows failures were introduced by the cleanup follow-up: AttachAndRun already closes the host window, disconnecting the handler and clearing CoreWebView2; a second disconnection threw in HybridWebView2Proxy.Disconnect. Commit 9fdfe272ab excludes Windows from additional cleanup, and 1605524 verified that correction in both modes.

Local validation

  • Shared-drawable regression: New test fails before Mutate() with an independently loaded resource rendered black, then passes with the fix. The original image test also passes. Ten earlier isolated image-category runs passed before this regression reproduced the shared-state problem.
  • Full Android Mono Controls: 982 passed, 0 failed, 12 existing skips (994 total), including both image regressions and existing SwipeItem alignment cases.
  • Full Android CoreCLR Controls: 972 passed, 10 memory/GC assertion failures, 12 existing skips (994 total). Both image regressions pass. Similar memory failures occurred before the drawable fix; assertions were not relaxed. This local run was not green, although subsequent build 1605524 passed the complete CoreCLR suite.
  • Functional cleanup: Earlier full Mono Controls run had 981 passed and 12 existing skips; a subsequent HybridWebView category had 92 passed and five existing skips. No causal local reproduction of the intermittent readiness timeout is claimed.
  • Android Essentials: 282/282 passed on Mono and CoreCLR. Temporarily removing the product duplicate-registration guard made both revised tests fail, including expected 1/actual 3 events. Product source was restored. The ordinary baseline also passed locally; this does not reproduce the intermittent live-event race.
  • Windows SDK selection: 9/9 checks passed for the full pinned version, version updates, explicit overrides, and unchanged other-platform selection.
  • Windows XML integrity: 15/15 Pester cases passed. Replaying the real 46-category packaged results returned zero; replaying the unpackaged results with its original empty Map file returned one while preserving the 45 readable category results.
  • Apple: Earlier iOS 18.5 MemoryTests had 64 passed plus one existing skip, twice, with all weak-reference assertions retained.

Limitations

The original main/SR11 comparison had identical relevant product/test source; no SDK regression is claimed. The Android drawable bug has a fail-before/pass-after reproduction, but the intermittent Apple readiness failure does not. Windows behavior cannot be executed locally on this macOS host and must be verified in CI. Local Android uses API 33 ARM64/workload 36.1.69 rather than CI's x64/workload 36.1.115; local iOS uses 18.5 rather than CI's 18.1. Local builds use the installed .NET 11 preview SDK targeting net10.0, with uncommitted UseMonoRuntime=false/PublishReadyToRun=false overrides for CoreCLR because local crossgen rejects Android. Final cross-platform verification requires actual current-head CI results.

Wait for Android image loading after attachment, wait for HybridWebView page readiness before Apple leak checks, and give the ten-navigation scenario a dedicated timeout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 20, 2026 18:59
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38713

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38713"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo

kubaflo commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The changes require final human review because they are too complex or risky for automated approval.

Review effort: Lite
Findings: None

What changed in this PR

Stabilizes Android and Apple device-test lifecycle timing without changing product code.

Changes:

  • Attaches Android image layouts before waiting for rendering.
  • Waits for HybridWebView readiness on Apple platforms.
  • Extends the nested tab-navigation test timeout to 30 seconds.
File Description
src/​Controls/​tests/​DeviceTests/​Memory/​MemoryTests.cs Updated as part of this pull request.
src/​Controls/​tests/​DeviceTests/​Elements/​TabbedPage/​TabbedPageTests.cs Updated as part of this pull request.
src/​Controls/​tests/​DeviceTests/​Elements/​Image/​ImageTests.cs Updated as part of this pull request.
src/​Controls/​tests/​DeviceTests/​Elements/​HybridWebView/​HybridWebViewTestsBase.cs Updated as part of this pull request.

Wait for the loaded native image to finish layout before asserting its pixels. Preserve intrinsic sizing and the original red-pixel assertion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 20, 2026 22:22
@kubaflo

kubaflo commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review effort: Lite
Findings: None

kubaflo and others added 2 commits September 21, 2026 13:31
Use the full pinned SDK package version for Windows Helix payloads instead of the shortened installed SDK version. Preserve explicit overrides and XHarness SDK selection on other platforms, with regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Run listener registration, simulated callbacks, assertions and cleanup in one UI-thread turn. Dispose both test managers so native callbacks cannot leak into subsequent tests. Preserve detection of duplicate registrations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 21, 2026 11:41
@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@kubaflo kubaflo changed the title Stabilize Android and iOS device-test lifecycle waits Stabilize device tests and fix Windows Helix SDK selection Sep 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Android HybridWebView readiness must be awaited before lifecycle and leak assertions.

Review effort: Lite
Findings: None

@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Mutate the drawable before applying SwipeItem icon styling. Add a regression that renders a separately loaded resource after tinting, and remove the image-layout workaround that did not address the failure.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 21, 2026 15:47
@kubaflo kubaflo changed the title Stabilize device tests and fix Windows Helix SDK selection Fix Android shared image tinting and stabilize device tests Sep 21, 2026
@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Full final-head device CI verification is still outstanding, with known unverified and locally failing suites.

Review effort: Lite
Findings: None

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 21, 2026 17:21
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Fix the Map readiness predicate’s off-by-one condition and complete current-head device CI verification.

Review effort: Lite
Findings: None

…st compilation

Heap dumps identify scrollbar-fading callbacks retaining detached item views beyond fast CoreCLR collection loops. Preserve the collection-attempt limit and leak assertions, allow pending native callbacks to run, and cover delayed release plus intentionally rooted objects.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 21, 2026 20:09
@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Full current-head device CI verification is still required, including Windows result completeness.

Review effort: Lite
Findings: None

Exit after RunTestsAsync disposes its result writer, preserve failure status for failed tests and runner errors, and keep strict CI exit/XML validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 21, 2026 21:40
@kubaflo

kubaflo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Full current-head device CI verification is still required across all Helix jobs and suite results.

Review effort: Lite
Findings: None

@kubaflo kubaflo closed this Sep 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants