Repository navigation
Conversation
|
The build 228776 found UI Test snapshots differences: Details
|
(cherry picked from commit 05091c4)
f9bc43e to
03733fa
Compare
There was a problem hiding this comment.
Pull request overview
Adds opt-in negotiated scrolling for BrowserHtmlElement on Skia WebAssembly, chaining native scroll residuals through managed ScrollViewers.
Changes:
- Adds managed scroll chaining and runtime coverage.
- Implements browser gesture negotiation, residual handoff, and inertia.
- Adds policy APIs, CSS behavior, documentation, and a manual sample.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Summary / review note |
|---|---|
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.ScrollChaining.cs |
Managed ancestry-based residual scroll chaining. |
src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.Managed.cs |
Touch-aware presenter scrolling and inertia configuration. |
src/Uno.UI/NativeElementHosting/BrowserHtmlElement.wasm.cs |
WebAssembly input-policy behavior. |
src/Uno.UI/NativeElementHosting/BrowserHtmlElement.skia.cs |
Skia input-policy bridge. |
src/Uno.UI/NativeElementHosting/BrowserHtmlElement.reference.cs |
Reference platform implementation. |
src/Uno.UI/NativeElementHosting/BrowserHtmlElement.cs |
Public InputPolicy API. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_ScrollChaining.cs |
Scroll-chaining regression coverage. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/WasmCSS/uno.css |
Negotiated touch behavior. Moderate finding (2 votes): excluded native subtrees can inherit the negotiated root’s touch-action: pinch-zoom, potentially blocking native selection or scrolling. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts |
Browser gesture negotiation, residual handoff, and inertia. Moderate finding (2 votes): custom native fling starts regardless of the ancestor ScrollViewer’s inertia setting. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserNativeElementHostingExtension.ts |
Policy registration and host lifecycle handling. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/Native/BrowserNativeElementHostingExtension.cs |
Managed host registry and bridge. |
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/Devices/Input/BrowserPointerInputSource.cs |
JavaScript-to-managed scroll bridge. |
src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml_Controls/BrowserHtmlElementTests/BrowserHtmlElement_NativeScrollNegotiation.xaml.cs |
Manual sample behavior. |
src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml_Controls/BrowserHtmlElementTests/BrowserHtmlElement_NativeScrollNegotiation.xaml |
Manual sample UI. |
doc/articles/features/using-skia-hosting-native-controls.md |
Feature documentation. |
Suppressed comments (12)
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/WasmCSS/uno.css:112
touch-actionis intersected with the values of its ancestors, andhtml, bodyabove still settouch-action: none. This descendant declaration cannot re-enablepinch-zoomfor negotiated content (especially when there is no inner DOM scroll container), so the documented pinch-zoom behavior is not actually available. The ancestor touch-action policy needs to permit this gesture or the implementation needs a different arbitration mechanism.
#uno-native-element-host > [data-uno-native-input-policy="1"],
#uno-native-element-host > [data-uno-native-input-policy="1"] *:not(:is(input, textarea, select, [contenteditable])):not(:is(input, textarea, select, [contenteditable]) *) {
touch-action: pinch-zoom !important;
overscroll-behavior: none !important;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserNativeElementHostingExtension.ts:195
- The JS policy lookup is map-backed, but the CSS gate still trusts the caller-settable
data-uno-native-input-policyattribute written here. A root can receive value1through the publicSetHtmlAttributeAPI (or hosted script) without a WeakMap registration; CSS then disables native panning whilegetInputPolicyreturns null, so neither Uno chaining nor browser panning handles the gesture. The CSS marker must not be independently spoofable, or the managed registration and CSS state must be enforced together.
public static setInputPolicy(elementId: string, unoElementId: number, value: number) {
const element = this.getElementOrThrow(elementId);
BrowserHtmlElement.inputPolicies.set(element, { policy: value, unoElementId: unoElementId });
element.dataset.unoNativeInputPolicy = value.toString();
}
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserNativeElementHostingExtension.ts:194
- Changing the policy only updates the registry and CSS attribute; it does not cancel
_nativeScrollGestureor_nativeScrollInertiaGesture. IfInputPolicyis changed fromNegotiatedtoNativeOnlywhile a drag/fling is active, subsequent events take the native-only early return, leaving the old state alive (and allowing the fling to continue); the next pointer-down can then be misclassified as a second pointer. Cancel the active negotiated state when disabling the policy.
public static setInputPolicy(elementId: string, unoElementId: number, value: number) {
const element = this.getElementOrThrow(elementId);
BrowserHtmlElement.inputPolicies.set(element, { policy: value, unoElementId: unoElementId });
element.dataset.unoNativeInputPolicy = value.toString();
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:431
- Wheel events use the default
isIntermediate: truehere, but this branch never callscompleteNativeScrollafterward. When a wheel over native content is handed to aScrollViewer, everyViewChangedremains intermediate and the snap-points timer is stopped, so consumers never observe the end of the wheel scroll. Match the existingPointerWheelScrollpath by reporting each wheel delta as terminal (or explicitly completing it).
const didScroll = this.applyNativeScrollDelta(gesture, evt.deltaX, evt.deltaY);
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:431
- This path consumes
WheelEvent.deltaX/deltaYbefore the normal pipeline'sdeltaModeconversion below. Firefox line-mode and page-mode wheel events therefore reach the native scroller and Uno parent as line/page units interpreted as pixels, producing incorrect scroll distances. Normalize the deltas using the sameDOM_DELTA_LINE/DOM_DELTA_PAGEhandling before applying them.
const didScroll = this.applyNativeScrollDelta(gesture, evt.deltaX, evt.deltaY);
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:409
- When browser zoom is disabled, Ctrl+wheel should still reach the normal managed pipeline, where
ScrollContentPresenter.PointerWheelScrolluses Ctrl+wheel forScrollViewerzoom. This condition instead negotiates it as a scroll and prevents that managed zoom path. Leave all Ctrl+wheel events to the normal pipeline; that pipeline already suppresses browser default behavior when browser zoom is disabled.
if (evt.ctrlKey && BrowserInputHelper.isBrowserZoomEnabled) {
return false;
}
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:449
- The second-pointer escape is only checked after
getNativeInputHostsucceeds. If the second finger lands on an Uno surface or outside this native root,tryHandleNegotiatedNativeInputis never called for thatpointerdown; the first gesture remains active and subsequent moves continue to be prevented, so the browser cannot take over the multi-touch/pinch gesture as documented. Track a new pointer globally while a negotiated gesture is active, before target-policy filtering.
if (evt.type === "pointerdown") {
if (this._nativeScrollGesture !== null && this._nativeScrollGesture.pointerId !== evt.pointerId) {
// A second finger means a multi-touch gesture (pinch/zoom) which this negotiation does not
// arbitrate. Drop our single-pointer gesture and leave the whole interaction to the browser,
// which still has pinch-zoom available (see the touch-action rule in uno.css).
this.completeNativeScroll(this._nativeScrollGesture);
this._nativeScrollGesture = null;
return false;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:389
- Active gestures are looked up from the current event target. Because explicit pointer capture is disabled in this source, a pen gesture that leaves the native root is no longer recognized here; its later
pointerup/pointercancelgoes through the normal path, leaving_nativeScrollGesturewithout inertia or completion. Once a pointer ID is tracked, route its move/up/cancel by that state regardless of the current target, or capture it explicitly.
private tryHandleNegotiatedNativeInput(evt: PointerEvent | WheelEvent): boolean {
const host = this.getNativeInputHost(evt.target);
if (host === null || host.policy === NativeElementInputPolicy.NativeOnly) {
return false;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:427
- Wheel deltas are incorrectly given a touch-style primary-axis lock here.
applyNativeScrollDeltathen zeroes the smaller component, so diagonal trackpad wheel input drops one axis; the existing normal pipeline dispatches horizontal and vertical wheel components independently. Wheel gestures should bypass this axis lock.
primaryAxis: Math.abs(evt.deltaX) > Math.abs(evt.deltaY) ? "horizontal" : "vertical",
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:279
- Once any boundary residual is observed, this boolean permanently bypasses
scrollTargetfor the rest of the pointer sequence. If the user reverses direction before lifting, the native scroller has available range again but every delta is still sent to Uno, so chaining is not actually negotiated per delta. Re-evaluate native consumption when direction changes (ideally per axis) instead of making ownership sticky.
if (Math.abs(remainingHorizontalDelta) > 0.01 || Math.abs(remainingVerticalDelta) > 0.01) {
gesture.unoOwnsGesture = true;
}
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:540
- Native inertia is only canceled from inside
tryHandleNegotiatedNativeInput(the wheel/pointerdown cases below). A new pointerdown on the canvas, a NativeOnly host, or an excluded control follows the early-return path here and leaves the old requestAnimationFrame fling running. That fling can continue callingOnNativeScrollDeltawhile the new interaction is scrolling the same ancestor; cancel the JS fling whenever a new input sequence supersedes it.
if (this.isEventFromNativeElementHost(evt.target)) {
if (this.tryHandleNegotiatedNativeInput(evt)) {
return;
}
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_ScrollChaining.cs:288
- This test's comment says completion must produce exactly one terminal notification, but the assertion only checks that at least one
falseexists. A regression that raises multiple terminalViewChangedevents for the same viewer would still pass. Assert that the count of non-intermediate states is exactly one to lock the contract described by the new implementation.
Assert.IsTrue(intermediateStates.Contains(false), "Completing the gesture must raise a non-intermediate ViewChanged.");
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
The build 229071 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Suppressed comments (13)
src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml_Controls/BrowserHtmlElementTests/BrowserHtmlElement_NativeScrollNegotiation.xaml.cs:37
- The sample's native HTML surface hardcodes a white background and black foreground, so it becomes a light, potentially low-contrast box when the SamplesApp is in dark theme while the surrounding XAML uses ThemeResource brushes. Use theme-aware CSS/custom properties (or otherwise derive these colors from the current theme) for the native content.
("border", "2px solid #0078d4"),
("padding", "12px"),
("background", "white"),
("color", "black"));
src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml_Controls/BrowserHtmlElementTests/BrowserHtmlElement_NativeScrollNegotiation.xaml.cs:31
- The sample creates an owned DOM element but never disposes it. Leaving the page only detaches/hides the element; it does not remove it from
#uno-native-element-host, so each visit leaves another hidden native node and associated managed/JS policy state behind. Dispose the element from the page's unload lifecycle (and clear the reference) after detaching it.
_nativeElement = BrowserHtmlElement.CreateHtmlElement("div");
_nativeElement.InputPolicy = EnableNegotiatedInput.IsChecked is true
? BrowserHtmlElementInputPolicy.Negotiated
: BrowserHtmlElementInputPolicy.NativeOnly;
NativeHost.Content = _nativeElement;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/Native/BrowserNativeElementHostingExtension.cs:60
- The guard protects the host registry, but this unconditional detach still hides the DOM element. If the same BrowserHtmlElement is attached to a new ContentPresenter before the old presenter detaches (the scenario described by the comment above), the old detach hides the element and breaks the new host's rendering and negotiation. Only call the native detach when the registry is absent/dead or still points to this extension.
NativeMethods.DetachNativeElement(element.ElementId);
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/WasmCSS/uno.css:112
- The TypeScript path explicitly treats iframes as native-only, but this selector still applies
touch-action: pinch-zoomandoverscroll-behavior: noneto an iframe (and a nested iframe element). Pointer events from the embedded document do not reach this handler, so a single-finger iframe scroll can be disabled with no native or Uno consumer. Exclude iframes from the CSS selector as well as the TypeScript path.
#uno-native-element-host > [data-uno-native-input-policy="1"],
#uno-native-element-host > [data-uno-native-input-policy="1"] *:not(:is(input, textarea, select, [contenteditable])):not(:is(input, textarea, select, [contenteditable]) *) {
touch-action: pinch-zoom !important;
overscroll-behavior: none !important;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/WasmCSS/uno.css:110
- The root selector is not subject to the form/contenteditable exclusions applied to descendants. If the BrowserHtmlElement itself is an
input,textarea,select, or contenteditable root, the TypeScript path correctly leaves it native, but this rule still forcestouch-action: pinch-zoomandoverscroll-behavior: none, disabling the native panning/selection behavior promised by the API and potentially leaving no handler to pan. Apply the same:not(:is(input, textarea, select, [contenteditable]))filter to the root selector.
#uno-native-element-host > [data-uno-native-input-policy="1"],
#uno-native-element-host > [data-uno-native-input-policy="1"] *:not(:is(input, textarea, select, [contenteditable])):not(:is(input, textarea, select, [contenteditable]) *) {
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/WasmCSS/uno.css:112
- The form/contenteditable exclusions only remove the rule from the excluded element and its descendants; the negotiated root itself still forces
touch-action: pinch-zoom. Browsers compute the effective touch action by intersecting the touched element with its ancestors, so native controls or a non-scrollablecontenteditablesubtree can still lose single-finger native selection/scroll behavior despite the JSclosest()exclusion. The policy needs a way to leave a native subtree outside the negotiated touch-action boundary, rather than only excluding its descendants from this selector.
#uno-native-element-host > [data-uno-native-input-policy="1"],
#uno-native-element-host > [data-uno-native-input-policy="1"] *:not(:is(input, textarea, select, [contenteditable])):not(:is(input, textarea, select, [contenteditable]) *) {
touch-action: pinch-zoom !important;
overscroll-behavior: none !important;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserNativeElementHostingExtension.ts:195
- Changing
InputPolicytoNativeOnlyonly updates the policy map and attribute; it does not cancel an already scheduled inertia RAF. If the sample or an app toggles the policy while a fling is running, the stored gesture continues invokingOnNativeScrollDeltaand can keep scrolling the ancestor ScrollViewer after negotiation has been disabled. Cancel the matching active/inertial gesture when switching away fromNegotiated.
public static setInputPolicy(elementId: string, unoElementId: number, value: number) {
const element = this.getElementOrThrow(elementId);
BrowserHtmlElement.inputPolicies.set(element, { policy: value, unoElementId: unoElementId });
element.dataset.unoNativeInputPolicy = value.toString();
}
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:540
- Once a negotiated gesture is active, this path is still gated by the current event target. With pointer capture disabled, a normal drag can leave the native root (or enter an excluded input/contenteditable subtree), after which the pointer-up/cancel bypasses this handler and
_nativeScrollGestureis never cleared or completed. The managed ScrollViewer can therefore miss its terminal ViewChanged and the stale gesture can interfere with the next pointer sequence; route the active pointer by its stored id or explicitly cancel/complete it when the target leaves the negotiated surface.
if (this.isEventFromNativeElementHost(evt.target)) {
if (this.tryHandleNegotiatedNativeInput(evt)) {
return;
}
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:435
- Wheel events use the default
isIntermediate: truehere, but this path never callsOnNativeScrollCompletedfor the local wheel gesture. Consequently any residual handed to a ScrollViewer is reported as intermediate forever: consumers never receive the terminalViewChanged, and snap-point scheduling that runs on a non-intermediate update is skipped. Wheel updates should be reported as terminal (or the burst needs an explicit completion).
const didScroll = this.applyNativeScrollDelta(gesture, evt.deltaX, evt.deltaY);
if (didScroll) {
evt.preventDefault();
}
return true;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:518
- Every negotiated touch ends by starting the custom JavaScript fling, without checking
ScrollViewer.IsScrollInertiaEnabled. The managed direct-manipulation path explicitly stops when that property is false (ScrollContentPresenter.Managed.cs:679-683), so an app that disables inertia still receives extra native/ancestor scrolling after lifting the pointer. The native bridge needs to query/gate this setting or delegate inertia to the managed path.
if (gesture.started) {
this.startNativeScrollInertia(gesture);
if (this._nativeScrollInertiaGesture === null) {
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_ScrollChaining.cs:70
- Each test calls
UITestHelper.Load, which assignsWindowHelper.WindowContent, but the class never clears that shared visual tree. A failed assertion or the next test can therefore inherit the previous ScrollViewer and its event handlers/state; wrap each test's loaded content in atry/finallythat restoresWindowHelper.WindowContent = null.
await UITestHelper.Load(outer);
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_ScrollChaining.cs:22
- These tests directly cover issue #24134, but the runtime-test convention requires issue-covering tests to carry a
GitHubWorkItemURL for traceability. Add the attribute for issue 24134 at the class (or test) level.
[TestClass]
[RunsOnUIThread]
public class Given_ScrollViewer_ScrollChaining
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:434
- The negotiated wheel path passes raw
deltaX/deltaYto the scroller. Unlike the normal path below, it does not convertDOM_DELTA_LINEorDOM_DELTA_PAGEto pixels, so Firefox and other line/page-mode wheel sources scroll by the wrong amount and hand an incorrectly sized residual to Uno. Normalize the deltas before selecting the primary axis and applying the native/managed scroll.
This issue also appears in the following locations of the same file:
- line 431
- line 537
const didScroll = this.applyNativeScrollDelta(gesture, evt.deltaX, evt.deltaY);
if (didScroll) {
evt.preventDefault();
}
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24138/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24138/wasm-skia-net9/index.html |
|
The build 229088 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Suppressed comments (14)
Previously missed (4) — in code that hasn't changed since the last review.
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/WasmCSS/uno.css:116
- The CSS side trusts a caller-mutable data attribute as the marker for negotiated input. Hosted code can set
data-uno-native-input-policy="1"on the root even when the managed policy isNativeOnly; the TypeScript map will still return NativeOnly, but this rule will disable native panning withtouch-action: pinch-zoom/overscroll-behavior: none, leaving the gesture with no consumer. The CSS marker must not be writable by hosted content, or the CSS state must be protected/reconciled from managed state.
#uno-native-element-host > [data-uno-native-input-policy="1"]:not(:is(input, textarea, select, iframe, [contenteditable])),
#uno-native-element-host > [data-uno-native-input-policy="1"] *:not(:is(input, textarea, select, iframe, [contenteditable])):not(:is(input, textarea, select, iframe, [contenteditable]) *) {
touch-action: pinch-zoom !important;
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:430
- The normal wheel pipeline converts
DOM_DELTA_LINEandDOM_DELTA_PAGEbefore handing deltas to managed scrolling, but this path passes the raw values directly toscrollTop/scrollLeftand the residual bridge. On browsers that report line/page units, a wheel tick will move by a few pixels or one pixel instead of the intended line/page distance. Normalizeevt.deltaModebefore this call, preferably through a shared helper with the normal path.
const didScroll = this.applyNativeScrollDelta(gesture, evt.deltaX, evt.deltaY);
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:430
- This is a one-shot wheel gesture, but the call leaves
isIntermediateat its defaulttrueand the wheel branch never callscompleteNativeScroll. When a wheel delta reaches the Uno parent, everySetis therefore intermediate and no terminalViewChanged(IsIntermediate: false)is raised. Treat each wheel event as terminal (or explicitly complete a coalesced burst), matching the existingPointerWheelScrollpath.
const didScroll = this.applyNativeScrollDelta(gesture, evt.deltaX, evt.deltaY);
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_ScrollChaining.cs:335
- The comment says completion must produce exactly one terminal
ViewChanged, but this assertion only checks that at least onefalsevalue exists. A regression that emits multiple terminal notifications would pass; assert the count of non-intermediate entries is exactly one.
Assert.IsTrue(intermediateStates.Contains(false), "Completing the gesture must raise a non-intermediate ViewChanged.");
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/Native/BrowserNativeElementHostingExtension.cs:60
- The registration is removed before
NativeMethods.DetachNativeElementruns, but the JS detach implementation first cancels an active fling and synchronously callsOnNativeScrollCompleted. That callback then cannot find this host in_hosts, so a fling that had handed off to Uno never receives its terminalViewChanged(IsIntermediate: false)when the native element is detached. Complete the gesture before unregistering, or defer removal while preserving the recycled-host identity check.
if (_hosts.TryGetValue(element.UnoElementId, out var registered)
&& (!registered.TryGetTarget(out var host) || ReferenceEquals(host, this)))
{
_hosts.Remove(element.UnoElementId);
}
NativeMethods.DetachNativeElement(element.ElementId);
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/Native/BrowserNativeElementHostingExtension.cs:56
- The ownership guard protects only
_hosts: if a new presenter attaches the sameBrowserHtmlElementbefore the old presenter detaches, this condition leaves the map pointing at the new presenter, but line 60 still callsdetachNativeElementand hides the DOM element. The new presenter then has a registered but hidden host. Only detach the DOM element when this instance still owns the registration.
// Only drop the registration if it is still ours: when an element is recycled, the new host can
// attach before the old one detaches, and unregistering then would silently kill its chaining.
if (_hosts.TryGetValue(element.UnoElementId, out var registered)
&& (!registered.TryGetTarget(out var host) || ReferenceEquals(host, this)))
{
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserNativeElementHostingExtension.ts:194
- Updating the policy map does not cancel
_nativeScrollInertiaGesture. IfInputPolicychanges fromNegotiatedtoNativeOnlywhile a fling is running (the sample exposes this toggle), the existingrequestAnimationFrameloop continues to callOnNativeScrollDeltaand scroll the ancestor even though opt-in is now off. Cancel the active gesture/inertia when disabling or changing the policy before updating the map.
public static setInputPolicy(elementId: string, unoElementId: number, value: number) {
const element = this.getElementOrThrow(elementId);
BrowserHtmlElement.inputPolicies.set(element, { policy: value, unoElementId: unoElementId });
element.dataset.unoNativeInputPolicy = value.toString();
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:506
- After the touch/pen threshold, this unconditional
preventDefault()also runs for ordinary selectable text; only form controls andcontenteditablesubtrees are excluded. A touch selection drag in a static paragraph is therefore canceled and routed as scrolling, contrary to the newBrowserHtmlElementInputPolicydocumentation and PR behavior claim that text selection remains native. Preserve that selection path or narrow the public contract.
this.applyNativeScrollDelta(gesture, horizontalDelta, verticalDelta);
evt.preventDefault();
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:539
- This branch only invokes
tryHandleNegotiatedNativeInputwhile the current event target is still under#uno-native-element-host. Pointer capture is disabled above and pen pointers are not guaranteed implicit capture, so a pen drag that leaves the hosted element sends subsequentpointermove/pointerupevents through the normal path;_nativeScrollGestureis then never cleared or completed, and a handed-off gesture misses its terminal update. Handle an active negotiated pointer bypointerIdbefore requiring the current target to be a native host, and cancel/finalize it when it leaves.
if (this.isEventFromNativeElementHost(evt.target)) {
if (this.tryHandleNegotiatedNativeInput(evt)) {
return;
}
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:281
- Once any residual is detected,
unoOwnsGestureis latched and the native target is never visited again. If the user reverses direction before lifting, the native scroller may be able to consume the new delta again, but this code continues routing all movement to the outerScrollViewer, leaving the inner surface stuck for the rest of the drag. Re-evaluate native consumption for each delta (or explicitly return ownership when the direction becomes consumable) instead of making handoff permanent.
if (Math.abs(remainingHorizontalDelta) > 0.01 || Math.abs(remainingVerticalDelta) > 0.01) {
gesture.unoOwnsGesture = true;
}
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_ScrollChaining.cs:22
- These tests cover the behavior tracked by issue #24134 but do not carry the repository's required issue-traceability attribute. Add
GitHubWorkItemat the class level so the regression tests remain linked to the issue they guard.
[TestClass]
[RunsOnUIThread]
public class Given_ScrollViewer_ScrollChaining
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.ScrollChaining.cs:75
- This absorption does not match the existing direct-manipulation contract: when
ScrollContentPresenterhas no local inertia (IsScrollInertiaEnabled == false),OnUpdatedleaves the inertial delta unhandled so an outerScrollViewercan consume it (ScrollContentPresenter.Managed.cs:628-635). Zeroing the residual here stops the fling at the inner viewer instead, and the following chaining-disabled logic reinforces that behavior. Preserve the residual for outer viewers when local inertia is refused if this bridge is to mirror the managed pipeline.
if (isInertial && !scrollViewer.IsScrollInertiaEnabled)
{
// Mirrors IDirectManipulationHandler.OnInertiaStarting: with inertia opted out, this ScrollViewer
// neither moves during the inertial phase nor lets the fling continue past it on the axes it takes
// part in - an outer ScrollViewer flinging while this one stands still would look broken.
if (scrollsHorizontally)
{
remainingHorizontalDelta = 0;
}
if (scrollsVertically)
{
remainingVerticalDelta = 0;
}
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.ScrollChaining.cs:92
ChainScrollFromDescendantalways passesisTouch: trueto the presenter, but the browser also routesWheelEvents through this method.ScrollContentPresenter.SetusesIsTouchto skip completing_touchInertia, so a managed fling already running when the user wheels over a negotiated native element can continue fighting the wheel movement. Distinguish wheel input from touch/inertia or complete the managed inertia before applying the wheel delta.
isTouch: true);
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.ScrollChaining.cs:113
- When
CanHorizontallyScrollis false,scrollsHorizontallyis false, so this condition never absorbs a residual even whenIsHorizontalScrollChainingEnabledis false. The delta can then reach an outer ScrollViewer, unlikeIDirectManipulationHandler.OnUpdated, which clears the axis whenever the chaining flag is disabled. Apply the chaining flag to the remaining axis delta independently ofCanHorizontallyScroll(and likewise for the vertical axis).
if (scrollsHorizontally && !scrollViewer.IsHorizontalScrollChainingEnabled)
{
remainingHorizontalDelta = 0;
}
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24138/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24138/wasm-skia-net9/index.html |
|
The build 229255 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/BrowserPointerInputSource.ts:294
- applyNativeScrollDelta() returns only the managed OnNativeScrollDelta result once gesture.unoOwnsGesture becomes true. When the native scrollTarget consumed part of the delta (hit its boundary) but no ScrollViewer could scroll, this returns false and the WheelEvent path will not call preventDefault(), allowing the browser to also process the wheel (which can cause double-scroll/overscroll). Return true if either the native scrollTarget moved or Uno consumed any delta.
return BrowserPointerInputSource._exports.OnNativeScrollDelta(
gesture.unoElementId,
remainingHorizontalDelta,
remainingVerticalDelta,
isIntermediate,
isInertial) !== 0;
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24138/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24138/docs/index.html |
|
The build 230360 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.ScrollChaining.cs:141
- CompleteChainedScrollFromDescendant calls presenter.Set(...) for every ScrollViewer ancestor, which will raise ViewChanged(IsIntermediate: false) even for ScrollViewers that never participated in the chained scroll (e.g., a ScrollViewer in the ancestry with both axes disabled, where ChainScrollFromDescendant never called presenter.Set). This can introduce unexpected terminal ViewChanged events on unrelated/disabled scrollers.
if (ancestor is ScrollViewer { Presenter: { } presenter })
{
// No offset is passed: this only re-reports the offsets already in place, with
// IsIntermediate false to close the sequence of intermediate deltas.
presenter.Set(disableAnimation: true, isIntermediate: false, isTouch: true);
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24138/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24138/docs/index.html |
|
The build 230396 found UI Test snapshots differences: Details
|
|
|
|
Tick the box to add this pull request to the merge queue (same as
|
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
|
…6.7/pr-24138 fix(wasm): Chain BrowserHtmlElement scrolling to the enclosing ScrollViewer (backport #24138)
GitHub Issue: related to #24134
PR Type:
🐞 Bugfix
What changed? 🚀
Current behavior. On Skia WebAssembly, a touch gesture that begins inside a
BrowserHtmlElementdoes not participate in the enclosing UnoScrollViewer. A scrollable native child consumes the whole gesture and dead-stops at its own boundary, and a drag that starts over non-scrollable native HTML does not scroll the enclosingScrollViewerat all. This is most visible on tablets, where an embedded editor or grid can occupy most of the viewport and effectively traps the page.There are two independent causes:
ScrollVieweris painted onto the canvas and is not a DOM scroll container, sooverscroll-behaviorand the browser's own scroll chaining have nothing to chain into.BrowserPointerInputSource.onPointerEventReceivedearly-returns for any event targeting#uno-native-element-host, so Uno never observes the gesture.This PR adds an opt-in
BrowserHtmlElement.InputPolicy:With
Negotiated, a scrollable native child scrolls first and transfers only what it could not consume at its boundary to the enclosingScrollViewer, chaining outwards; a gesture over non-scrollable native content goes to theScrollViewerdirectly. Taps, focus, text selection and native control interaction stay native. The default (NativeOnly) preserves today's behavior exactly.Managed side
ScrollViewer.ChainScrollFromDescendantwalks theScrollViewerancestry and hands each one the residual the previous could not take. Two details matter:ClearOffsetIntents()+ the presenter'sSet), notScrollViewer.ChangeView.ChangeViewarms the ScrollViewer's offset intent, which the post-layout recompute re-applies — so overshooting at a boundary (as every fling does) parked an intent past the end of the content, and the next extent growth snapped the view to it. This is covered by a regression test that fails against theChangeViewimplementation.IsTouch: true, IsIntermediate: true, with a single non-intermediate change when the gesture ends. Reporting every frame as terminal firedViewChanged(IsIntermediate: false)at 60–120 Hz and restarted the snap-points timer mid-fling.Chaining honors
IsHorizontalScrollChainingEnabled/IsVerticalScrollChainingEnabled, per-axis, matchingIDirectManipulationHandler.OnUpdated.Browser side
Gesture detection, native-first scrolling and the residual bridge live in
BrowserPointerInputSource.ts. Notable hardening over a naive implementation:#uno-native-element-host) — never by reading adata-attribute off the event target. Hosted HTML is app- or third-party-supplied and must not be able to opt itself into a policy the app did not set. The managed host registry is keyed on theGCHandle, not the caller-settableElementIdstring.OnNativeScrollDeltais wrapped in try/catch with anIsEnabled-guarded error log and appliesNativeDispatcher.Main.SynchronizationContext, matching the neighbouringOnNativeEvent. Non-finite deltas are rejected before reachingValidateInputOffset, which throws onNaN.input,textarea,select) andcontenteditableregions — and their descendants — keep full native touch behavior and never participate in chaining. The CSS and TypeScript exclusion lists are deliberately kept in sync; a mismatch produces a subtree that neither the browser nor Uno will pan.touch-action: pinch-zoomrather thannone, so multi-finger zoom survives. A second pointer abandons negotiation and hands the interaction back to the browser.isBrowserZoomEnabled.Iframes remain native-only: pointer events do not cross the frame boundary, so an embedded document's scroll residual cannot be observed.
The first commit is cherry-picked from an external contributor's branch with authorship preserved; the remainder is rework following an internal review.
Validation
Runtime tests (Skia Desktop) — 13 tests in
Given_ScrollViewer_ScrollChaining, all passing, covering forward/backward chaining, boundary residual, chaining-disabled absorption, horizontal, non-finite deltas, and the intermediate/terminalViewChangedsequence. The offset-intent regression guard was verified to fail against the pre-fix implementation and pass after.Regression — 241/243 passing across
Given_ScrollViewer,Given_ScrollViewer_Anchoring,Given_ScrollViewer_Zoom,Given_ListView*andGiven_FlipView(16 skipped). The one failure,Given_ListViewBase.When_ThemeChange, was verified to fail identically on cleanmasteron the same machine and is unrelated.Manual, iPadOS Safari — the core scenarios pass on device: drag over non-scrollable native content scrolls the page, the native scroller hands over residual at its boundary without stalling, reverse chaining works, and flick inertia carries across the handoff.
touch-actionchange. Marked as draft until they are covered.PR Checklist ✅
Screenshots Compare Test Runresults.