Skip to content

fix(hr): Probe runtime platform for hot-reload TFM on skia-mobile heads - #23790

Merged
dr1rrb merged 3 commits into
masterfrom
dev/dr/hr-skia-mobile-runtime-tfm
Jul 20, 2026
Merged

dr1rrb merged 3 commits into
masterfrom
dev/dr/hr-skia-mobile-runtime-tfm

Conversation

@dr1rrb

@dr1rrb dr1rrb commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes unoplatform/uno-private#2256

PR Type:

🐞 Bugfix

What changed? 🚀

On skia-rendering Android/iOS (and Mac Catalyst/tvOS) heads, hot reload detects XAML/C# changes but never applies them on the device.

The client computed the platform part of its RuntimeTargetFramework from compile-time symbols (__ANDROID__ & co.). Those symbols are meaningless on skia-rendering mobile heads: the uno-runtime asset selection swaps the plain-netX.0 skia flavor of Uno.UI.RemoteControl.dll in for the per-platform one, so no platform symbol is defined and the client reports the netX.0-skia pseudo-TFM. The server then restricts the hot-reload workspace to the desktop flavor of the head (Hot-reload workspace restricted to 'net10.0-desktop' for the application's 'net10.0-skia'), and the metadata updates are computed for a target framework the device never runs.

This PR probes the platform at runtime through OperatingSystem checks instead (IsAndroid(), IsTvOS(), IsMacCatalyst() — tested before IsIOS() since Catalyst also reports it — IsIOS(), IsBrowser()), which stays correct in every flavor of the assembly. Desktop heads still report the skia pseudo-TFM, which the server already treats as the netX.0-desktop/netX.0 family; the server-side matching is unchanged.

On the server side, the workspace target-framework filtering now systematically logs the loaded flavors, the target framework the application reported and the flavors kept — including the previously-silent single-flavor path (project single-targeted, or TargetFramework already pinned by the IDE at evaluation). When that single loaded flavor does not match the reported target framework — a workspace pinned to the wrong flavor, from which updates will most likely not apply — it is surfaced as a warning.

Validated with the Uno.HotReload.Tests suite (76 passing, now also asserting the filtering traces and the mismatch warning); the platform probe itself is runtime-OS dependent and covered by the existing server-side matching tests consuming the reported values.

PR Checklist ✅

The client computed the platform of its RuntimeTargetFramework from
compile-time symbols (__ANDROID__ & co.). Those symbols are meaningless
on skia-rendering android/ios/maccatalyst/tvos heads: the uno-runtime
asset selection swaps the plain-netX.0 skia flavor of
Uno.UI.RemoteControl.dll in for the per-platform one, so the client
reported the 'netX.0-skia' pseudo-TFM and the server restricted the
hot-reload workspace to the desktop flavor, leaving detected changes
never applied on the device.

Probe the platform at runtime through OperatingSystem checks instead,
which stays correct in every flavor of the assembly.
Copilot AI review requested due to automatic review settings July 16, 2026 14:31
@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @dr1rrb's task in 2m 1s —— View job


Code Review

  • Gather context and understand the request
  • Read the changed file
  • Review for correctness, style, and cross-platform conventions
  • Post inline comments (none needed — no blocking issues found)
  • Post summary

Summary

Verdict: Ship it. No blocking issues. The fix is correct, minimal, and follows the framework's platform-targeting conventions exactly.


Analysis

Root cause is correctly identified and addressed. The Uno.UI.RemoteControl.dll in the netX.0 (skia) slot is swapped in by the uno-runtime asset selector for skia-on-Android/iOS/etc. heads — so the compile-time symbols (__ANDROID__, __IOS__, ...) were never defined in that compilation and the old #if chain silently fell through to "skia". The fix correctly moves to OperatingSystem.IsXxx() runtime probes, which is exactly what .claude/rules/platform-targeting.md rule #4 prescribes for "one assembly serving many OSes at runtime."

Platform probe order is correct:

  • IsMacCatalyst() before IsIOS() — documented in the comment and critical, since Catalyst returns true for both
  • IsBrowser() before the "skia" fallback — catches WASM (both the legacy native flavor and skia-on-browser)
  • Desktop (Windows/macOS/Linux) correctly falls through to "skia", which the server already maps to the desktop TFM family

OperatingSystem API availability — all five checks (IsAndroid, IsTvOS, IsMacCatalyst, IsIOS, IsBrowser) are in the .NET base library since .NET 5 and always return false on non-matching platforms. No compatibility concern on net10.0.

Comment length — the 7-line block comment is above the "a line or two" guideline in code-style.md, but the exception clause applies here: the uno-runtime asset-selection mechanism is genuinely non-obvious and cannot be adequately explained in one line. The comment earns its length, and in particular the IsMacCatalyst() ordering note is a critical invariant that future readers need.

No async/event/DependencyProperty/allocation concerns — the method is a static helper that returns a string; it has no I/O, no async void, no allocations beyond the final interpolated string.

Test coverage — the PR description explains that the platform probe is inherently runtime-OS-dependent and is exercised indirectly by the existing server-side TFM-matching suite (74 tests passing). A dedicated unit test would require mocking OperatingSystem, which is not mockable; the indirect coverage via the matching suite is the reasonable approach here.

@dr1rrb
dr1rrb marked this pull request as ready for review July 16, 2026 14:32
@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @dr1rrb's task in 2m 24s —— View job


Code Review

  • Gather context
  • Review changed file
  • Post inline comments (if any)
  • Post summary

Summary

Verdict: LGTM — the change is a correct, targeted root-cause fix with no identified bugs.

What the fix does (in brief): The skia-flavor Uno.UI.RemoteControl.dll is a single assembly that gets swapped in by the uno-runtime asset selector for netX.0-android, netX.0-ios, etc. heads, where compile-time __ANDROID__/__IOS__ symbols are never defined. Before this fix the client always fell to the else branch and reported net10.0-skia, causing the server to restrict the hot-reload workspace to the desktop head while the device ran the mobile one — a mismatch that silently dropped all metadata updates.

Checks:

Area Assessment
Approach ✅ OperatingSystem.Is*() runtime probes are exactly the prescribed pattern for a single assembly serving multiple OS runtimes (per .claude/rules/platform-targeting.md rule 4)
Ordering ✅ IsMacCatalyst() tested before IsIOS() is required and correct — on Mac Catalyst, IsIOS() also returns true; IsTvOS() has no overlap with either so its position is fine
browserwasm case ✅ OperatingSystem.IsBrowser() correctly covers both the legacy native-WASM and the modern skia-on-WASM browser heads
Server-side matching ✅ RuntimeTargetFrameworkMatches handles android, ios, tvos, maccatalyst, and browserwasm through generic platform-identifier comparison (version suffix stripped); skia/desktop/`` are treated as equivalent for the desktop family — unchanged and correct
Comment ✅ The 7-line block is long by house style, but the asset-selection substitution mechanism is a genuine non-obvious invariant that warrants the explanation
maccatalyst/tvos server test coverage ⚠️ Given_RuntimeTargetFrameworkMatching does not have explicit rows for net10.0-tvos or net10.0-maccatalyst. Not a blocker — the generic TryParseShortTargetFramework + exact platform comparison handles them correctly — but a few DataRow entries would make intent explicit
Conventional commit ✅ fix(hr): ...
Checklist items The "runtime tests" box is unchecked; the PR description explains why (OS-dependent, covered by server-side matching tests). Acceptable.

No inline comments — no blocking issues found.

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

Fixes hot-reload target-framework reporting on Skia-rendering mobile heads (Android/iOS/Mac Catalyst/tvOS) by deriving the platform portion of the runtime TFM from runtime OS detection rather than compile-time symbols, ensuring the server computes metadata updates against the correct target.

Changes:

  • Replace compile-time platform symbol checks with OperatingSystem.Is*() runtime probes when composing RuntimeTargetFramework.
  • Update the method documentation to reflect the new runtime-based platform detection approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dr1rrb added 2 commits July 16, 2026 07:41
…ing path

The single-flavor path (project single-targeted, or TargetFramework
already pinned by the IDE at evaluation) returned without any trace,
leaving a workspace pinned to the wrong flavor invisible in the logs.
The restriction message also omitted which flavors had been loaded.

Every path of FilterHeadProjectTargetFramework now reports the loaded
target frameworks, the one the application reported and the ones kept.
When the workspace holds a single flavor of the head project (single-
targeted, or TargetFramework pinned by the IDE at evaluation) that does
not match the target framework the application reported, updates
emitted from it will most likely not apply; surface it as a warning
instead of a plain trace. Unresolved flavors keep the neutral trace, a
mismatch cannot be asserted for them.
Copilot AI review requested due to automatic review settings July 16, 2026 14:47
@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @dr1rrb's task in 2m 52s —— View job


Code Review

  • Gather context and understand the request
  • Read the changed files
  • Review for correctness, style, and cross-platform conventions
  • Post inline comments (none — no blocking issues found)
  • Post summary

Summary

Verdict: Ship it.

The fix is a correct, well-scoped root-cause repair. No blocking issues found across all four changed files.


Analysis

Root cause and fix: The skia-rendering mobile heads load the netX.0 (plain) skia flavor of Uno.UI.RemoteControl.dll via Uno's runtime asset selector, meaning __ANDROID__ / __IOS__ / etc. compile-time symbols were never defined in that compilation context. The old #if chain silently fell through to the "skia" branch regardless of the actual OS. Replacing with OperatingSystem.IsXxx() runtime probes is exactly what .claude/rules/platform-targeting.md rule 4 prescribes for "one assembly serving many OSes at runtime" — no concerns there.

Platform probe order is correct. IsMacCatalyst() before IsIOS() is required (Mac Catalyst returns true for both) and is documented in the comment. IsTvOS() has no overlap with either so its position is fine. IsBrowser() correctly covers both native WASM DOM and Skia-on-browser. Desktop falls through to "skia", which _skiaDesktopPlatforms = ["", "desktop", "skia"] maps to either spelling.

TryParseShortTargetFramework + RuntimeTargetFrameworkMatches logic is correct. Verified the early-return path for bare netX.0 (no dash) correctly leaves platformIdentifier = "" and returns true; then matching with net10.0-skia works because both "" and "skia" are in _skiaDesktopPlatforms.

Single-flavor warning path in FilterHeadProjectTargetFramework (new in this PR): the condition resolved && !string.IsNullOrWhiteSpace(runtimeTargetFramework) && !RuntimeTargetFrameworkMatches(...) is correct — it avoids speculating a mismatch when the TFM can't be resolved (unloaded/broken project), which the When_SingleFlavor_And_TfmUnresolvable_Then_SolutionIsUnchanged_And_TracesWithoutWarning test explicitly covers.

RecordingReporter: Thread-safe via System.Threading.Lock (available on .NET 9+/10+). Separate captures for verbose/output/warnings/errors. The _verbose list has no public accessor — correct given no test needs to assert on verbose-level messages.

Test coverage is appropriate: the five SingleFlavor test cases cover matched, mismatched, unresolvable TFM, and head-not-found paths. When_RuntimeIsMobile_Then_MobileFlavorIsKept exercises the platform-version-tolerant matching for the reported-vs-project TFM pair that was the direct trigger for this bug.

Comment length: the 7-line block at ClientHotReloadProcessor.cs:172–178 is above the "a line or two" house style but falls squarely under the documented exception — the uno-runtime asset-selection substitution is a genuine non-obvious invariant, and the IsMacCatalyst()-before-IsIOS() ordering note is a critical invariant a future reader needs. No concern.

No async/cancellation, DependencyProperty, event, or allocation concerns in the changed code.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@unodevops

Copy link
Copy Markdown
Contributor

dr1rrb added a commit that referenced this pull request Jul 16, 2026
…ime-tfm-66

fix(hr): Probe runtime platform for hot-reload TFM on skia-mobile heads (backport #23790)
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 222647 has failed on Uno.UI - CI.

@dr1rrb
dr1rrb merged commit d5fd498 into master Jul 20, 2026
63 of 67 checks passed
@dr1rrb
dr1rrb deleted the dev/dr/hr-skia-mobile-runtime-tfm branch July 20, 2026 17:10
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.

4 participants