Skip to content

ci: run iOS device tests on arm64#4961

Merged
jpnurmi merged 5 commits intomainfrom
ci/ios-devtest-arm64
Mar 2, 2026
Merged

ci: run iOS device tests on arm64#4961
jpnurmi merged 5 commits intomainfrom
ci/ios-devtest-arm64

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Feb 27, 2026

System.Reflection.Emit is blocked on ARM64 simulators due to W^X. The Mono interpreter (<UseInterpreter>true</UseInterpreter>) already handles this, so switching from x64/Rosetta to iossimulator-arm64 works with the current build settings.

Motivated by / unblocks using Cirrus CI runners that come with non-Universal ARM64-only Simulator runtimes:

#skip-changelog

System.Reflection.Emit is blocked on arm64 simulators due to W^X — this is
what NSubstitute/Castle.DynamicProxy needs:
https://learn.microsoft.com/en-us/dotnet/maui/macios/interpreter

The Mono interpreter bypasses this by interpreting emitted IL instead of
generating native code. Sentry.Maui.Device.TestApp.csproj already has
<UseInterpreter>true</UseInterpreter> for Release, and the build already
passes EnableAot=false. So the two workarounds are redundant — either x64
via Rosetta OR the interpreter alone should suffice. Switching to
iossimulator-arm64 should work with the current build settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.89%. Comparing base (1753b23) to head (a55c177).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4961      +/-   ##
==========================================
+ Coverage   73.87%   73.89%   +0.01%     
==========================================
  Files         496      496              
  Lines       17951    17951              
  Branches     3516     3516              
==========================================
+ Hits        13262    13265       +3     
+ Misses       3831     3825       -6     
- Partials      858      861       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi jpnurmi force-pushed the ci/ios-devtest-arm64 branch 2 times, most recently from 8bf3565 to 2b92506 Compare February 27, 2026 12:32
jpnurmi and others added 2 commits February 27, 2026 14:27
mlaunch (inside xharness) checks if simulator watchdogs are disabled
before launching an app. If they aren't, it shuts down the simulator,
writes plist files, then reboots — this sequence is flaky on CI, often
leaving the simulator stuck in a Shutdown state with:
  "Unable to lookup in current state: Shutdown"

Root cause was found by decompiling mlaunch with ilspycmd (it ships as
a compiled DLL in the xharness NuGet). It checks two plists under the
simulator's data directory:
  ~/Library/Developer/CoreSimulator/Devices/$UDID/data/Library/Preferences/
    - com.apple.springboard.plist
    - com.apple.frontboard.plist

All 6 FBLaunchWatchdog* keys must be >= 100, otherwise mlaunch shuts
down the sim to write them and reboots — which races on CI.

Fix: pre-write both plists with the 6 keys set to 100 before booting
the simulator ourselves. mlaunch then sees watchdogs already disabled
and the sim already booted, skipping its entire shutdown/reboot dance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the ci/ios-devtest-arm64 branch from 2b92506 to d10ed15 Compare February 27, 2026 13:28
@jpnurmi jpnurmi changed the title WIP: ci: run iOS device tests on arm64 ci: run iOS device tests on arm64 Feb 27, 2026
@jpnurmi jpnurmi force-pushed the ci/ios-devtest-arm64 branch 2 times, most recently from a44a1e3 to d10ed15 Compare February 28, 2026 09:17
@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 28, 2026

I had a lot of trouble getting iOS Device Tests pass at all. xharness/mlaunch/simctl would repeatedly get stuck while either installing or running the test app. Claude suggested the problem is related to how mlaunch disables simulator watchdogs and restarts the simulator. Bumping xharness to 11.0 seems to improve the flow a bit:

xharness 10.0 (3 boots):

  1. Boot → Booted
  2. "watchdogs not disabled" → shutdown → "No need to boot (already booted)"
  3. --launchsimbundleid: "simulator running, but device not booted" → Boot again → Booted

vs.

xharness 11.0 (2 boots):

  1. Boot → Booted
  2. "watchdogs not disabled" → shutdown → "Device already booted and simulator is running"
  3. (no third boot needed)

With xharness 11.0, 4/5 iOS Device Tests runs passed:

@jpnurmi jpnurmi marked this pull request as ready for review February 28, 2026 16:00
Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

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

So this is just something that they've fixed in the .NET sdk or the mono runtime now? We didn't used to be able to run the iOS device tests on arm64 but how we can?

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Mar 2, 2026

The key change that made it work is that the W^X security restriction is no longer applicable after adding UseInterpreter=true in #3699: https://learn.microsoft.com/en-us/dotnet/maui/macios/interpreter

@jpnurmi jpnurmi merged commit 815d9fb into main Mar 2, 2026
45 of 46 checks passed
@jpnurmi jpnurmi deleted the ci/ios-devtest-arm64 branch March 2, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants