Commit 8498a4b
Address API and code review on the modal navigation seam
API review and code review found blocking issues in the seam. This applies
all of them.
Recursion (blocking): IModalNavigationHost.IsModalReady folded
IModalNavigationPlatform.IsReady back in, so the natural implementation
`IsReady => host.IsModalReady && ...` recursed into an uncatchable
StackOverflowException. Replaced with IsWindowReady, which is framework
readiness only (window handler + page handler) and is documented as safe to
consult from IsReady.
Threading (blocking): IModalNavigationHost.RequestSync documented itself as
callable from any thread but ran readiness checks, page lifecycle events and
platform presentation on the calling thread. It now marshals the whole
reconciliation entry through the window scope's IDispatcher when a dispatch
is required, and the remaining synchronous reentrancy on the UI thread is
documented.
Failure semantics: a faulting custom PopModalAsync removed the page from
PlatformModalStack and never restored it, so a still-visible native modal
became absent from both stacks and unreachable. Push and pop now follow one
rule: the requested stack is intent, PlatformModalStack is reality, and a
faulted operation restores reality to "did not take effect" so the next
reconciliation pass retries. Push fault removes, pop fault restores.
Deferred pop animation: the pop request leaves the logical stack before the
deferred reconciliation runs, so the reconciled pop always got animated:false
and the caller's flag was silently dropped. Pending pop animation metadata is
now retained until the platform actually dismisses the modal.
Deferred completion: the docs promised faults are rethrown to the navigation
caller, but a deferred operation completes that caller before the platform
runs and the later sync is fire-and-forget. Rather than change when
navigation completes, the contract now states exactly when a fault reaches
the caller (inline application) and when it is logged instead (deferred).
Lifecycle: teardown is now terminal for the override so it cannot be lazily
recreated or leaked after Window.Destroying; only attaching a new handler,
which brings a new service scope, re-enables resolution. A throwing factory
is logged and falls back to the built-in platform permanently instead of
escaping from an arbitrary call site or retrying on every access.
PageAttached is now keyed on the page handler instance, which fixes a real
doubling: the page-change sync can resolve the override before
PageAttachedHandler runs.
Also documents that teardown does not pop still-presented modals and Dispose
must not assume MauiContext is usable, that native dismissals must be routed
back through Navigation.PopModalAsync and PopModalAsync must be idempotent,
and that IsBatchPopping is a Shell-only optimization hint. Adds IsBatchPushing
for symmetry. The factory example no longer uses IPlatformViewHandler, which
external backends cannot compile against, and uses the public TFM-neutral
DisconnectHandlers instead.
Adds regressions for recursion avoidance, background-thread RequestSync
marshalling, inline RequestSync, push and pop fault rollback, fault recovery
by reconciliation, deferred pop animation in both directions, platform
dismissal round-trip, throwing factory, no resurrection after destroy,
recreation on new handler, teardown with presented modals, and late
resolution delivering PageAttached exactly once. Each was verified to fail
against a mutation of the corresponding fix.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent 881947b commit 8498a4b
13 files changed
Lines changed: 922 additions & 75 deletions
File tree
- src/Controls
- src/Core
- PublicAPI
- net-android
- net-ios
- net-maccatalyst
- net-tizen
- net-windows
- netstandard
- net
- tests
- Core.UnitTests
- DeviceTests/Elements/Modal
Lines changed: 61 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
| |||
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
75 | 100 | | |
76 | 101 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 102 | + | |
| 103 | + | |
80 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
81 | 112 | | |
82 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
83 | 125 | | |
84 | 126 | | |
85 | 127 | | |
86 | 128 | | |
87 | 129 | | |
| 130 | + | |
88 | 131 | | |
89 | 132 | | |
90 | 133 | | |
91 | 134 | | |
92 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
93 | 146 | | |
94 | 147 | | |
95 | 148 | | |
| |||
Lines changed: 81 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
27 | 49 | | |
28 | 50 | | |
29 | 51 | | |
30 | 52 | | |
31 | 53 | | |
32 | 54 | | |
33 | 55 | | |
| 56 | + | |
34 | 57 | | |
35 | 58 | | |
36 | 59 | | |
37 | 60 | | |
38 | 61 | | |
39 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
40 | 75 | | |
41 | 76 | | |
42 | 77 | | |
| |||
53 | 88 | | |
54 | 89 | | |
55 | 90 | | |
56 | | - | |
57 | | - | |
58 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
59 | 107 | | |
60 | 108 | | |
61 | 109 | | |
| |||
67 | 115 | | |
68 | 116 | | |
69 | 117 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
73 | 123 | | |
74 | 124 | | |
| 125 | + | |
75 | 126 | | |
76 | 127 | | |
77 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
78 | 145 | | |
79 | 146 | | |
80 | 147 | | |
81 | 148 | | |
82 | 149 | | |
83 | 150 | | |
84 | 151 | | |
| 152 | + | |
85 | 153 | | |
86 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
87 | 161 | | |
88 | 162 | | |
89 | 163 | | |
| |||
Lines changed: 37 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
| |||
35 | 45 | | |
36 | 46 | | |
37 | 47 | | |
| 48 | + | |
38 | 49 | | |
39 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
40 | 56 | | |
41 | | - | |
| 57 | + | |
42 | 58 | | |
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
46 | | - | |
| 62 | + | |
47 | 63 | | |
48 | 64 | | |
49 | 65 | | |
50 | 66 | | |
51 | | - | |
52 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
53 | 72 | | |
54 | 73 | | |
55 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
56 | 82 | | |
57 | | - | |
58 | | - | |
| 83 | + | |
| 84 | + | |
59 | 85 | | |
60 | | - | |
61 | | - | |
62 | 86 | | |
63 | 87 | | |
64 | 88 | | |
| |||
0 commit comments