Repository navigation
Nalu.Maui 11.3.0
This release ships a brand-new package, Nalu.Maui.LiveActivities, bringing iOS Live Activities and
Android 16 Live Updates to MAUI from a single C# content model, and Magnet 2.0: a full rewrite of the
constraint layout around a compiled constraint engine that replaces the Cassowary solver. Alongside those:
the Scaffold nav bar now renders the page's standard ToolbarItems, VirtualScroll's automatic ItemsSource
wrapping is AOT-compatible, and the iOS background HTTP handler received a round of hardening backed by a new
fault-injection harness that runs on the simulator and on a physical iPhone.
⚠️ Magnet 2.0 is a breaking change forNalu.Maui.Layouts: XAML written for Magnet 1.x does not
compile against 2.0. The migration guide
maps every 1.x concept to its 2.0 counterpart. See the "Breaking changes" section at the end.
📣 New package: Nalu.Maui.LiveActivities
Your app's live, glanceable state on the system surfaces of both platforms from one API (#207, #211, #219, #222):
- iOS: a real ActivityKit Live Activity (Lock Screen banner, Dynamic Island compact chip and expanded
card), rendered by a WidgetKit extension the package builds and embeds automatically: you write no Swift and
never open Xcode. DeclareNSSupportsLiveActivitiesinInfo.plistand you are done; forget it and the build
fails withNALU001telling you exactly what to add, so the mistake can never reach ActivityKit's cryptic
runtime error. Bespoke SwiftUI is one property away (NaluLiveActivitiesWidgetProject) when the bundled
widget is not enough. - Android 16 QPR1+: a Live Update, the promoted ongoing notification with the status-bar chip and the
floating card, using the API 36.1ProgressStyle(segments, milestone points, tracker icon). Android 8 through
base Android 16 degrade gracefully to a plain ongoing notification with a classic progress bar and a native
chronometer (Support == Degraded, opt-out viaDisableAndroidFallback). Both notification permissions are
merged into your manifest by the package;RequestPermissionAsync()triggers the runtime prompt.
The design principle is a semantic content model: you describe what the activity says (title, subtitle,
chip text, accent color, stepped progress, an OS-ticked timer, action buttons, a free-form Custom bag) and each
platform renders it natively in its own visual language.
builder.UseNaluLiveActivities(live => live.AddKind("delivery", "Order tracking"));
var activity = await liveActivities.StartAsync("delivery", new LiveActivityContent
{
Title = "Pizza on the way",
ChipText = "12 min",
Progress = new LiveActivityProgress { Value = 0.4 },
Timer = LiveActivityTimer.CountDown(order.Eta),
});
await activity.UpdateAsync(c => c.Progress!.Value = 0.8);
await activity.EndAsync(c => { c.Title = "Delivered"; c.Timer = null; });API shape
ILiveActivityManager(Support,RequestPermissionAsync,StartAsync,Activities) resolved from DI; on
Unavailablesurfaces (iOS < 16.2, Mac Catalyst, Windows)StartAsyncreturns an inert handle and every call is
a no-op, so app code is never platform-branched.- The
ILiveActivityhandle is write-mostly: every mutation is a synchronous patch lambda run on a deep-cloned
draft under the handle's lock. A patch producing identical content is skipped entirely (both OSes budget
updates). Updates are silent unless you pass aLiveActivityAlert.EndAsynckeeps the final content visible
by default on both platforms (Android converts it to a swipeable notification), or removes it with
LiveActivityDismissal.Immediate. - The user can always take it away, and the library honours it:
LiveActivityState.Dismissedplus an
ILiveActivity.Dismissedevent on both platforms. After a dismissalUpdateAsyncbecomes a silent no-op (so a
progress loop keeps running unchanged) andEndAsyncseals the handle without reposting what was swiped away. - Activities outlive your app: running activities are rehydrated into
Activitiesafter process death on
both platforms, from ActivityKit state on iOS and from the notification extras on Android. - Timers:
CountDown/CountUpticked by the OS.LiveActivityContent.SubtitleOverflowsets the wording
shown once a countdown passes its end (a plain count-up takes over); when null the overflow shows as a negative
duration. On iOS every ticking mode renders throughText(timerInterval:)for correct Lock Screen and
Always-On display fidelity. - Action and content taps on Android now reliably bring the app to the front (
CLEAR_TOP | SINGLE_TOP; the
previousNEW_TASK-only intent frequently delivered toonNewIntentwithout reordering the task).
Measured on device, so you don't have to
- A
StaleAtalready in the past makes ActivityKit create the activity directly in the stale state, and a stale
activity is never presented. The package drops such a date instead of forwarding it, which the documented
appointment pattern would otherwise hit the moment the countdown end goes by. - iOS ends any Live Activity after about 8 hours, and the Dynamic Island needs an iPhone 14 Pro or later
(notch devices only show the Lock Screen banner). Both are documented, with the reproduction that chased a
"does not show up for timers longer than 24h" report to those two causes.
Docs: Live Activities,
Timers,
Examples.
🧲 Magnet 2.0 (Nalu.Maui.Layouts)
A full rewrite of the constraint layout (#209, #210, #212, #213, #214, #215, #216, #217, #220, #221). The
Cassowary solver and the 1.x element model are gone.
Engine
- A pure compiler (id table, per-axis dependency graphs, cycle detection with readable error paths, a
topologically sorted instruction tape) and an allocation-free executor that resolves the content hug in
closed form: no solver iterations, zero allocations per measure/arrange. - Compiled tapes are pure and shared through a process-wide LRU cache keyed by the structure of the definition,
so template-instantiated cells compile once (Magnet.CompilationCacheCapacity, default 64). - Steady-state work was then trimmed further: fused chain runtime ops (a
Gapon a chain went from +22% to
+3.5%), child measures deferred to arrange when only the child needs them, and a delta arrange that replays
the measure's affine solution at the arrange size instead of re-executing the tape. - Every arrange in the unit suite is cross-checked against an unconditional full re-solve by a differential
verification harness (885/885), plus dedicated tests for the arrange-vs-measure boundaries.
Public API
MagnetDefinitionwithMagnetView,MagnetBarrier,MagnetGuidelineandMagnetChainnodes, all in the
Nalunamespace, every node identified by a mandatoryMagnetId.- Constraints are written directly on the child view through attached properties
(nalu:Magnet.LeftTo="avatar.Right,12",nalu:Magnet.TopTo="parent.Top"), withMagnetAnchorcarrying the
per-anchor margin and GONE margin ("a.Right,12,gone:0"),WidthSizing/HeightSizing("48","*",
"50%",{nalu:MagnetSizing 1.5, Unit=Ratio},Min/Max), biases, and theAfter/Below/Align*/
Within/Fill*shortcuts. A fluent C# builder covers the same surface.MagnetIdpropagates to
AutomationId(opt-out). - Explicit chains (
Spread/SpreadInside/Packed, weights, gap modes, measured members shrink to leave room),
barriers, guidelines,StagePercent/Ratio/Measuredsizing with bounded cross-axis feedback for ratios.
Nodes/Weightsaccept comma-separated attributes (Nodes="a,b") as well as element content. - Transitions:
TransitionToAsyncanimates value changes (input-interpolated) and structural changes
(frame-interpolated), with retargeting when a new transition lands mid-flight. - Scenes:
MagnetView.ApplyVisibility(None/Show/Hide) declares a one-shot visibility action stamped
onto the bound view'sIsVisiblewhen the definition is applied. Inside a transition aHidefreezes the view
in place and fades it out while siblings animate to the collapsed layout;Showfades in. Scenes have no
layout impact: definitions differing only in visibility actions share the same compiled tape, and a scene can
be toggled on a single definition without swapping it. - Shareable definitions: a
MagnetDefinitionis a pure declaration that any number ofMagnetlayouts can
attach to (an app-wide resource, a template shared by every cell). All per-layout state lives in the layout;
mutating a shared definition reaches every subscriber. Sharing one definition across cells trims per-cell
inflation allocations by 15%. - Nodes and the definition are plain
INotifyPropertyChangedobjects, no longerBindableObjects:
−69% bytes per inflation on a typical 7-node graph, and node property access is plain field access. They stay
valid binding sources; they were never reachable binding targets since they live outside the visual tree.
Performance (from the docs)
Managed algorithm only, Apple M-series: a full relayout costs 1.2–1.3× a trivial nested Grid with 3–4.7× fewer
allocations, and the flat Magnet card inflates faster than the three nested layouts it replaces. On device the
flat hierarchy wins every scenario, because every layout Magnet flattens away is a native view MAUI no longer
has to create, map and traverse:
| 200 cards, warm run | iPhone simulator | Android emulator (arm64) |
|---|---|---|
| Inflate → settled | Grid 1600 ms · Magnet 1352 ms (−16%) | Grid 1999 ms · Magnet 1219 ms (−39%) |
| Text change on every card → settled | Grid 253 ms · Magnet 185 ms (−27%) | Grid 390 ms · Magnet 102 ms (−74%) |
Docs: the Magnet page is rewritten, the 1.x → 2.0 migration guide
maps every concept, and Magnet by example
walks through twelve everyday layouts (login form, list rows, toolbars, barriers, chains, weights, ratio,
guidelines, visibility, packed + measured, vertical centering, gap modes under collapse) with screenshots
rendered by the real library on the iOS simulator.
🏛️ Scaffold
Toolbar items in the default nav bar (#225, closes #224)
The default bar now renders the page's standard MAUI ToolbarItems: nothing to migrate, nothing to bind.
<ContentPage.ToolbarItems>
<ToolbarItem Text="Save" Command="{Binding SaveCommand}" />
<ToolbarItem Text="Share" Priority="1" IconImageSource="{FontImageSource FontFamily=Material, Glyph=}" />
<ToolbarItem Text="Settings" Order="Secondary" Clicked="OnSettingsClicked" />
</ContentPage.ToolbarItems>- Native toolbar semantics, identical on iOS and Android: primary items become buttons in the trailing slot by
Priority, as many as fit, the rest and the secondary items fold behind a ⋮ overflow menu. - The title folds items before it truncates: the bar reserves the title's natural width (never less than
MinimumTitleWidth, 96 by default) and offers the items what is left. SetKeepTitleWhole="False"on
ScaffoldNavBarViewto prefer the items instead. ATitleViewis treated the same way, by its natural width. - The collection is live: items added, removed, reordered or re-prioritized after the page is shown are
reflected at once (MAUI's native toolbars ignore such changes). A tap runsCommandand raisesClicked;
disabled items (or a command whoseCanExecuteis false) are dimmed and inert. - Font icons declared without a
Colorare tinted with the effectiveNavBarForeground, so they recolor with
the bar over a photo header, through a scroll-driven ramp and across themes. The overflow menu is a floating
panel and follows the app theme instead unless styled. - New public, styleable primitives:
ScaffoldToolbarItemsView,ScaffoldToolbarItemButton,
ScaffoldToolbarOverflowButton,ScaffoldToolbarOverflowView;ScaffoldNavBarContext.ToolbarItemsexposes
the items to fully custom bars. An item'sAutomationIdlands on the button or menu row rendered for it.
Fixes
- Reopening a start-edge flyout while its previous presentation still owned the content view crashed on iOS with
UIViewControllerHierarchyInconsistency. Overlays are now torn down before the owner callbacks run
(open-state properties, closed events), on both platforms, so a reopen issued from those callbacks, or a
callback that throws, can no longer tie a native view to a retired controller. - Presenter disposal (handler disconnection) now discards every open overlay without animation and runs each
owner cleanup: a drawer open at disconnect time is no longer left "open" forever, and pending popup / bottom
sheet handles complete.
📜 VirtualScroll
-
AOT-compatible
ItemsSourceauto-wrapping. Automatic adapter creation no longer relies on
MakeGenericType/Activator.CreateInstance, so theNotSupportedExceptionunder AOT is gone and JIT and
AOT share one code path. Any mutableIListimplementingINotifyCollectionChangednow coerces to a
reorderable adapter; read-only lists such asReadOnlyObservableCollection<T>get a change-tracking one.
Drag-and-drop over an auto-wrapped list is a binding away, and theAdapterproperty now raises
PropertyChangedwhenItemsSourcechanges, so the binding follows collection replacement:<vs:VirtualScroll ItemsSource="{Binding Items}" DragHandler="{Binding Adapter, Source={RelativeSource Self}, x:DataType=vs:VirtualScroll}" />
A drag reorder uses
ObservableCollection<T>.Movewhen available (other subscribers see a singleMove
notification) and falls back toRemoveAt+Insertfor other lists. -
Fix (iOS): a burst of inserts right after the page appeared, before
UICollectionViewhad loaded its
initial content, died in UIKit's invalid-batch-updates assertion. Incremental updates issued before the first
laid-out data load, or after a data source swap, now go through a full reload instead. -
Fix (Android): a potential crash with a drag handler attached: the
ItemTouchHelperis now detached before
its callback is disposed (detaching firesclearViewon a still-recovering dragged item), and swapping the
drag handler no longer leaves the previous helper attached. -
Trimming: the reflective
Movelookup is suppressed for both the net9 (IL2070) and net10 (IL2075)
analyzers; it already had aRemoveAt+Insertfallback when trimming removed the method.
🌐 Core: iOS background HTTP (NSUrlBackgroundSessionHttpMessageHandler)
- Fix: crashes at startup on background launches. A managed exception escaping an Objective-C delegate
callback aborts the process (SIGABRT) and orphans every queued background-session event; seen in the field
when session callbacks arrive before the DI container is built. Every delegate callback is now guarded, and a
failure faults the pending request instead of the process. - Duplicate identifiers attach. A second
SendAsynccarrying anX-NSUrlRequest-Identifieralready in
flight no longer orphans the first awaiter forever: it attaches to the pending transfer and returns its
response, and itsCancellationTokencancels only its own wait. Once the request completes the identifier is
free again. DefaultTimeoutis now actually enforced. iOS ignores the per-request native timeout on background
sessions (verified on device: a 3 s value against a stalled server never fires), so the timeout is enforced
managed-side and surfaces as aTaskCanceledExceptionwrapping aTimeoutException, theHttpClient.Timeout
convention. It ticks only while the app is alive; a transfer surviving a process kill is governed by the
session's resource timeout.- Orphaned
.nsrequest/.nsresponse/.nsdownloadfiles left by a previous process (a kill during the
acknowledge window) are swept at delegate init; a staged download no longer leaks when deferred processing
throws; the request body file name is sanitized like the response path. NSURLErrorcodes map toHttpRequestException.HttpRequestError, matchingSocketsHttpHandler.- All of this is backed by a new fault-injection harness: a raw-socket chaos server (truncation, RST,
garbage, stalls, drips, redirect loops), callback-injection scenarios that drive every delegate branch with
fake tasks, and app-lifecycle tests (backgrounding,SIGKILL+ relaunch, mid-flight kills), green on the
simulator and on a physical iPhone. The semantics it proved are now documented: background sessions silently
retry connection faults until the resource timeout, garbage bytes surface as an HTTP/0.9 200, only redirect
loops fail fast, and uploads killed mid-body still complete.
🏗️ Build, CI and docs
- CI is restructured into per-platform builds (Android on Linux, iOS + Mac Catalyst on macOS, Windows on
Windows) whose partial packages are merged at the package level; the unit suite runs first on Linux with no
MAUI workloads and the docs site is published only on release (#206). - Every library single-targets to plain
net10.0on Linux (-p:AllTargetFrameworks=net10.0), which is how the
unit suite runs in agent containers. - Docs: three new Live Activities pages; the Magnet rewrite with examples gallery, migration guide and
regenerated performance tables; a "Toolbar items" section on the Scaffold nav bar page; VirtualScroll pages no
longer carry the AOT caveat; the Core page documents the identifier-attach semantics.
⚠️ Breaking changes
Magnet 2.0 (Nalu.Maui.Layouts): XAML and C# written for Magnet 1.x do not compile. The
migration guide has the full table; in short:
Nalu.MagnetLayout.*types are gone:MagnetStage→MagnetDefinition(Magnet.Stage→Magnet.Definition),
HorizontalBarrier/VerticalBarrier→MagnetBarrier,HorizontalGuideline/VerticalGuideline→
MagnetGuideline, implicit chains → an explicitMagnetChainnode.Magnet.StageId→Magnet.MagnetId(mandatory, unique, no auto-generated ids); the"Stage"id →"parent".HorizontalPullTarget/VerticalPullTarget→MagnetAnchor; no!traction;Margin/CollapsedMarginon
the element → per-anchor margin andgone:margin.Width/Height(SizeValue) →WidthSizing/HeightSizing(MagnetSizing): a bare number is now a
fixed size (1.x: a measured coefficient) and"50%"is now 50% of the span between the view's anchors
(1.x: of the stage); useUnit=Measured/Unit=StagePercentfor the old meanings.Collapsedis gone: visibility is read from the bound view'sIsVisible.- Nodes are no longer
BindableObjects: the*Propertystatics are gone andStyle/Setter/Trigger/
SetBindingon nodes are no longer possible. - Semantics changed on purpose: measure hugs the content, a collapsed view drops its own margins, barriers ignore
collapsed members, guidelinePositionadds toPercent, and aRatiowidth fed by a*/%height resolves
with a single cross-axis feedback iteration.
NSUrlBackgroundSessionHttpMessageHandler.DefaultTimeout (Nalu.Maui.Core, iOS): previously forwarded to
a native timeout that background sessions ignore, so it never fired. It now fires, as a TaskCanceledException
wrapping a TimeoutException. Raise it, or clear it, for transfers that legitimately outlive the default.
👨🏼💻 Contributors
@albyrock87 and @claude