Skip to content

[release/11.0.1xx-preview7] Fix Android PixelCopy analyzer failure - #37082

Closed
kubaflo wants to merge 1 commit into
release/11.0.1xx-preview7from
kubaflo/preview7-pixelcopy-platform-guard
Closed

[release/11.0.1xx-preview7] Fix Android PixelCopy analyzer failure#37082
kubaflo wants to merge 1 commit into
release/11.0.1xx-preview7from
kubaflo/preview7-pixelcopy-platform-guard

Conversation

@kubaflo

@kubaflo kubaflo commented Aug 4, 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!

Root Cause

The Preview 7 device-test Mono build enables CI platform analyzers. RenderAsync guards the private RenderUsingPixelCopyAsync call with OperatingSystem.IsAndroidVersionAtLeast(26), but CA1416 does not propagate that caller precondition into the helper body, so PixelCopy.Request is reported as reachable on Android 24.

Description of Change

Mark RenderUsingPixelCopyAsync with SupportedOSPlatform("android26.0"). This communicates the helper precondition to the analyzer and matches the existing runtime guard without changing screenshot behavior.

Validation

  • Exact Preview 7 base fails the CI-analyzer build with CA1416 at PixelCopy.Request.
  • The same net11.0-android37.0 Release build with ContinuousIntegrationBuild=true succeeds after the annotation.

Issues Fixed

Unblocks the Preview 7 Mono device-test build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9be49656-7117-4235-9d96-404779ab6b16
Copilot AI review requested due to automatic review settings August 4, 2026 12:47
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 4, 2026 12:47 — with GitHub Actions Inactive
@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@github-actions

github-actions Bot commented Aug 4, 2026

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 -- 37082

Or

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

@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 temporarily deployed to copilot-pat-pool August 4, 2026 12:47 — with GitHub Actions Inactive
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 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.

Pull request overview

This PR addresses a CA1416 platform-analyzer failure in the Android screenshot implementation by annotating the PixelCopy rendering helper with the appropriate minimum Android API support attribute, aligning the helper’s body with the existing runtime API-level guard at the call site.

Changes:

  • Add [SupportedOSPlatform("android26.0")] to RenderUsingPixelCopyAsync so CA1416 recognizes PixelCopy.Request as guarded by Android 26+ support.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 4, 2026 12:50 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 4, 2026 12:51 — with GitHub Actions Inactive
@github-actions github-actions Bot added area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android labels Aug 4, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 4, 2026 12:51 — with GitHub Actions Inactive
@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@PureWeen current head 209de0782b is proven and ready to merge.

  • Device build 1539169 uses synthetic merge df4499b5d0, whose second parent is this exact head.
  • Build Device Tests (Mono) now succeeds with 0 errors; the exact build log contains no PixelCopy CA1416 diagnostic. CoreCLR and Windows device-test builds also succeed.
  • The unmodified Preview 7 base fails the same CI build with CA1416 at PixelCopy.Request; adding the Android 26 annotation makes that exact build pass locally.
  • The only later device failure is the unrelated MacCatalyst CarouselView Does Not Leak With Default ItemsLayout GC flake on macOS 26. This PR changes only an Android platform annotation and cannot affect that test.

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adversarial review verdict: Ready

No findings. 3/3 reviewers agreed that the annotation is correct and complete:

  • The exact PixelCopy.Request(Window, Rect, Bitmap, …) binding requires android26.0, so the new contract precisely matches the native API.
  • The helper has one caller, dominated by the analyzer-recognized OperatingSystem.IsAndroidVersionAtLeast(26) guard; no unsafe or newly warned call site remains.
  • The attribute is private analyzer metadata only and introduces no runtime, public API, resource-lifetime, or cross-platform behavior change.

Test coverage: A new runtime test would exercise identical behavior before and after this metadata-only change. Analyzer-enabled build validation is the appropriate coverage for this fix; no additional test or code change is required.

Prior review status: No existing review threads; the prior automated review contained an overview only and no findings.

Methodology: 3 independent reviewers with adversarial consensus.

@kubaflo

kubaflo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of consolidating Preview 7 stabilization around #37081. This product-code change remains intentionally excluded from the test-only bundle.

@kubaflo kubaflo closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants