Skip to content

[WASM] Semantic scroller DOM scroll range and child positions do not match the ScrollViewer when accessibility is enabled #24867

Closed

Description

@MartinZikmund

Current behavior 🐛

On Skia WebAssembly with accessibility enabled, the semantic <div> of a ScrollContentPresenter (overflow: scroll) doesn't mirror the ScrollViewer's geometry:

  1. Wrong scroll range. The DOM scroll range comes from the semantic children only, not from the XAML extent. Content without a semantic node (a plain Border, spacing, etc.) adds nothing. The range also shifts while scrolling, because the children's top values change.
  2. Children are shifted twice. AddSemanticElement / OnSizeOrOffsetChanged position each semantic child with UIElement.GetTransform(child, semanticParent). On Skia that is Visual.TotalMatrix-based and already includes the presenter's scroll translation, so a child at content y=400 with VerticalOffset=300 gets top: 100px (viewport coordinates). Then UpdateNativeScrollOffsets also sets scrollTop on the same <div> (up to whatever the browser allows), which moves the children again.
  3. AT-initiated scrolls map to the wrong XAML offset. When a browser or screen reader scrolls the semantic scroller (for example by focusing an off-screen node), the absolute DOM scrollTop is applied as the XAML offset in OnScroll. That value is in a different coordinate space and range than the XAML offset.

The feedback loop that made ScrollViewer offsets snap back is tracked in #24596 (fix in #24597). This issue is the remaining geometry mismatch that #24596 calls out as a follow-up. Filtering the echoes doesn't fix it.

Expected behavior 🎯

The semantic scroller should mirror the ScrollViewer 1:1:

  • its scrollable area equals the XAML extent (scrollHeight == ExtentHeight, scrollWidth == ExtentWidth),
  • scrollTop/scrollLeft equal VerticalOffset/HorizontalOffset,
  • semantic children are positioned in content coordinates (the scroll offset is applied once, by the DOM scroll).

How to reproduce it (as minimally and precisely as possible) 🔬

Runtime test (add to Given_AccessibleScrollViewer, run on Skia WebAssembly):

  1. Enable accessibility (EnsureAccessibilityEnabledAsync() from WasmSemanticDomHelper).
  2. Create a 200x200 ScrollViewer containing a StackPanel with 20 Buttons (Height = 40, each with an AutomationProperties.Name). Extent is 800.
  3. scrollViewer.ChangeView(null, 300, null, disableAnimation: true) and wait for idle.
  4. Read the presenter's semantic <div> (uno-semantics-<Visual.Handle>): compare scrollHeight / scrollTop with ExtentHeight / VerticalOffset, and compare button 10's top (content y=400, expected 100px below the viewport top) with its semantic rect relative to the scroller.
[TestMethod]
[RunsOnUIThread]
[PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.SkiaWasm)]
public async Task When_Scrolled_Then_Semantic_Scroller_Matches_ScrollViewer_Geometry()
{
    await EnsureAccessibilityEnabledAsync();

    var panel = new StackPanel();
    Button? target = null;
    for (var i = 0; i < 20; i++)
    {
        var button = new Button { Content = "Item " + i, Height = 40, Width = 150 };
        AutomationProperties.SetName(button, "Item " + i);
        panel.Children.Add(button);
        if (i == 10) { target = button; }
    }

    var scrollViewer = new ScrollViewer { Width = 200, Height = 200, Content = panel };
    await UITestHelper.Load(scrollViewer);
    await UITestHelper.WaitFor(() => SemanticElementExists(target!), timeoutMS: 5000);

    var presenter = (UIElement)scrollViewer.Presenter!;
    string Js(string expr) => InvokeBrowserJs(
        $"(function(){{const e=document.getElementById('{GetSemanticElementId(presenter)}'); return e ? String({expr}) : 'null';}})()");

    scrollViewer.ChangeView(null, 300, null, disableAnimation: true);
    await UITestHelper.WaitForIdle();
    await Task.Delay(500);

    var scrollHeight = double.Parse(Js("e.scrollHeight"), CultureInfo.InvariantCulture);
    var scrollTop = double.Parse(Js("e.scrollTop"), CultureInfo.InvariantCulture);
    var itemTop = GetSemanticElementRect(target!)!.Value.Y - GetSemanticElementRect(presenter)!.Value.Y;

    Assert.AreEqual(scrollViewer.ExtentHeight, scrollHeight, 1);   // 800
    Assert.AreEqual(scrollViewer.VerticalOffset, scrollTop, 1);    // 300
    Assert.AreEqual(100, itemTop, 1);
}

Note: this WebAssembly test is the intended repro. I could not run it in my environment (no wasm-tools workload), so the DOM-side numbers are not measured. The XAML side below was run.

What I did run on Skia Desktop: the same layout, reading the transform from the button to the presenter, the same matrix the accessibility code uses for top/left:

Extent=800 Viewport=200 Offset=300
item 10, TransformToVisual(presenter) y: before scroll = 400, after ChangeView(300) = 100

So the position handed to the semantic DOM already has the scroll offset subtracted, and scrollTop = VerticalOffset is applied on top of it.

Workaround 🛠️

None for apps that enable accessibility.

Works on UWP/WinUI

N/A (Uno-specific WebAssembly accessibility layer).

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

WebAssembly

Uno.Sdk version (and other relevant versions) 📦

master at 47267e7 (7.0), net11.0-browserwasm

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

Confirmed by code inspection on master (47267e7) plus the Skia Desktop transform check above. Root cause:

Suggested direction: position the direct semantic children of a scroll port in content coordinates (undo the presenter's offset), and size the scrollable area to the XAML extent. Don't add an extra child to do it, because that would shift the addSemanticElement child indices. A CSS custom property on the scroller driving an ::after sizer would work. Then scrollTop mirrors the offset 1:1.

Related: #24596 (echo revert), #24597 (echo filter), #24605 (focus mirroring scrolls the scroller).

Help us help you

No response

Activity

  1. added
    kind/bug
    platform/wasm 🌐
    triage/untriaged
    area/skia ✏️
    area/a11y
    area/scrollviewer ⏬
    difficulty/medium 🤔
    on Oct 1, 2026
  2. added
    7.1
    on Oct 14, 2026
  3. added a commit that references this issue on Oct 23, 2026
    7606b02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    7.1area/a11yarea/scrollviewer ⏬area/skia ✏️difficulty/medium 🤔kind/bugplatform/wasm 🌐triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions