Skip to content

Given_RichEditBox.When_Advanced_Math_Layout_Is_Bounded_And_Maps_Scripts fails intermittently on the WebAssembly CI job #26016

Open

Description

@Xiaoy312

Current behavior 🐛

The runtime test Given_RichEditBox.When_Advanced_Math_Layout_Is_Bounded_And_Maps_Scripts (src/Uno.UI.RuntimeTests/Microsoft/UI/Xaml/Controls/Given_RichEditBox.Math.skia.cs) fails intermittently in the WebAssembly Skia Runtime Tests 3 job:

Assert.IsTrue failed. 'condition' expression: 'preSup.Y < baseRect.Y'.

The failing step lays out <mmultiscripts><mi>T</mi><mi>i</mi><mn>2</mn><mprescripts/><mi>j</mi><mn>3</mn></mmultiscripts> and expects the pre-superscript 3 to sit above the base 𝑇. On the failing runs it doesn't. The earlier mover/munder/munderover steps in the same test pass.

Frequency. Measured with Azure DevOps Analytics on 2026-11-03:

Onset. The first failing master build, 242458, is at 769af4a (2026-10-30). The master merges just before it include #25817 (Keep WASM Arabic fallback in its script's font). Its commit a339542 changes UnicodeText so that a Common or Inherited character stays in the run's fallback font when that font has the glyph. Digits such as the 3 in the failing step are Common-script characters, and the neighbouring 𝑗/𝑇 are mathematical alphanumerics that resolve through a fallback font. This is a hypothesis from timing and code inspection only; it has not been bisected or reproduced locally. If it holds, the flakiness would come from which fallback font has finished loading on WASM when the layout runs.

Expected behavior 🎯

The test passes reliably on WebAssembly, as it does on the other platforms. The pre-superscript should be positioned above the base regardless of font-loading timing.

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

CI only so far, in the Tests - WebAssembly / Skia Runtime Tests 3 job, at about 25% per build.

A local attempt would run Given_RichEditBox.When_Advanced_Math_Layout_Is_Bounded_And_Maps_Scripts on the WASM Skia head, repeated with UITEST_RUNTIME_TESTS_ITERATIONS, ideally as part of shard 3 so earlier tests have loaded (or not loaded) the same fonts. Running it before and after a339542 would confirm or rule out the hypothesis above.

Workaround 🛠️

Re-run the failed WebAssembly job. On earlier builds the job passed on re-run (for example 242458, 242679, 243116).

Affected platforms 📱💻🖥️

WebAssembly

Uno.Sdk version (and other relevant versions) 📦

master (CI) since 769af4a, and release/stable/7.0.

IDE version 🧑‍💻

N/A (CI)

Anything else we need to know? 💬

Tracked alongside the known flaky runtime tests in #9080. Not to be confused with #25600 (the three WebGPU Given_RichEditBox caret/selection/stress tests).

Activity

  1. added
    triage/untriaged
    on Nov 4, 2026
  2. Xiaoy312 commented on Nov 4, 2026

    @Xiaoy312
    ContributorAuthor

    Update: root cause found, and it isn't #25817's UnicodeText change. I reproduced the failure deterministically on a local WASM build of current master.

    Mechanism

    On WebAssembly, the font RichEditBox uses for math depends on download timing:

    • The font is picked once per app run, in a Lazy<string> (RichEditTextDocument.MathRenderingFontFamilyName).
    • It takes a candidate only when the font resolves synchronously. In the browser, "Noto Sans Math" resolves that way only if the fallback service has already downloaded it from raw.githubusercontent.com because some earlier text needed it.
    • Otherwise it falls back to Open Sans, which has no OpenType MATH table, and that choice holds for the rest of the run.
    • The failed FontDetailsCache lookup is memoized as well. In the cold run, GetFont("Noto Sans Math", 16) later returned Noto Mono even after Noto Sans Math had loaded.

    So the math layout this test measures depends on whether an earlier test in the shard has finished downloading Noto Sans Math by the time math is first used.

    Repro. Three runs of the same mmultiscripts layout, each in a fresh browser session, using a throwaway diagnostic test:

    Math font picked preSup.Y vs base.Y Result
    Cold (nothing downloaded yet) Open Sans (OTMath=False, scriptScale 0.7) 0.0 vs 8.3 passes
    Noto Sans Math loaded by family name before first math use Noto Sans Math (OTMath=True, scriptScale 0.6) 1.4 vs 0.0 fails, postSup fails too
    Only a plain TextBlock showing 𝑇 ran first (codepoint fallback, as an earlier CI test would) Noto Sans Math 1.4 vs 0.0 fails

    (Local build was net10.0-browserwasm in Edge; CI runs net11 in Chrome. The logic involved is managed, so that shouldn't matter.)

    The cold result stays the same after Noto Sans Math finishes downloading in that run: the editor keeps using Open Sans. The isolated CI retry is effectively the cold case, which is why it always passes. In the failing shard-3 runs, every in-process retry fails the same way within ~0.5 s, which fits state left by earlier tests rather than timing inside this test.

    Two things to fix

    1. Product: on WASM the math font shouldn't depend on whether an unrelated fallback download has completed. Either resolve or request the math font explicitly and re-layout when it arrives, or stop memoizing the negative result.
    2. Test: preSup.Y < baseRect.Y compares the tops of caret/line boxes of different fonts at different scales. With Noto Sans Math, the base's line box is 53.7 px tall at 36 px, so its top sits far above the glyph. The superscript is still raised (its centre is ~9 px above the base's). Comparing baselines or centres would test the intent without depending on font ascent. When_Structured_Math_Layout_Maps_Core_Markers makes the same comparison for msubsup and could fail the same way once Noto Sans Math is the math font.

    Correction to the original description: a339542 can't affect this. Its branch needs currentFontDetails != inline.FontInfo, which a single-token layout never reaches. Why failures start on 2026-10-30 is still unverified. The likeliest explanation is that #25817's other commit (9888593, which changes which fallback families are fetched) changed when Noto Sans Math lands relative to the first math use in shard 3.

  3. Xiaoy312 commented on Nov 4, 2026

    @Xiaoy312
    ContributorAuthor

    Follow-up: what downloads Noto Sans Math in shard 3, and why this started on 2026-10-30.

    Trigger. The runtime-test runner shows each test name, with its DataRow arguments, in its status TextBlock. In shard 3, Given_CurrencyFormatter.When_FormatDoubleWithSpecialCurrencyCode runs well before Given_RichEditBox. Its AED row (د.إ.‏) and then its BHD row (د.ب.‏) make that TextBlock request Arabic letters from the browser fallback service. The coverage table lists the basic Arabic letters (U+0627–U+064A) under both Noto Sans Arabic and Noto Sans Math.

    The race in CoverageTableFontFallbackService, since 9888593 (#25817):

    1. U+062F (Dal, from AED) starts the Noto Sans Arabic download.
    2. If U+0628 (Beh, from BHD) is requested before that download finishes, it is queued for the next batch.
    3. When that batch runs, Arabic is already in _fetchedFonts. GetUntriedFamilies(U+0628) finds no untried script font, so it returns the untried symbol font. BuildCoverageMap uses that list, so the batch downloads Noto Sans Math, even though Noto Sans Arabic already covers the letter.
    4. Noto Sans Math is now loaded, so MathRenderingFontFamilyName picks it, and the test fails as described above.

    Before 9888593, BuildCoverageMap read the raw table. The greedy selection then picked Noto Sans Arabic again (it covers more of the batch), so Noto Sans Math was never downloaded on this path. That is the 10-30 onset. I checked this by reading the code, not by running the old code.

    Why only some builds. In CI the AED → BHD rows are only 0.16–0.64 s apart, and the Arabic font comes from raw.githubusercontent.com. Whenever that download takes longer than the gap, the race is hit. I can't measure CI's download times from the logs, so the ~1-in-4 rate is an inference. Locally the rows are about 1 s apart and the download takes about 0.1 s, so a full local run of shard 3 (same test order as CI) passes.

    Reproduction (local net10.0-browserwasm, Edge):

    Run Noto fetches Math font Result
    Fallback service only, Arabic fetch held open while Dal then Beh are requested [Noto Sans Arabic, Noto Sans Math] n/a extra Noto Sans Math download
    When_FormatDoubleWithSpecialCurrencyCode + this test, Arabic download delayed by 1.5 s the second batch includes U+0628, U+062C, U+0645 and fetches Noto Sans Math Noto Sans Math fails preSup.Y < baseRect.Y
    Same, no delay no Noto Sans Math before this test Open Sans passes

    Fix for the fallback service. Before selecting families for a batch, FetchFontsForMissingCodepoints should drop the queued codepoints that FindFetchedFamilyForCodepoint can now resolve. The first row above can serve as the fail-before test. That stops the unneeded ~1 MB download. On its own it doesn't remove the order dependency described earlier, because any test that shows a real math character before this one would still change which font RichEditBox uses for math.

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

    triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions