Skip to content

0.24.0

Latest

Choose a tag to compare

@adam-zethraeus adam-zethraeus released this 22 Nov 19:21
694f737

Added

  • RunLoopTestHarness in the SwiftTUITestSupport product, as ratified
    Testing SPI (@_spi(Testing)). It builds a view on the real run loop with
    a virtual frame clock, so a test in a package outside swift-tui steps an
    animation or a transition frame by frame with advanceToNextWake() and
    advance(by:), delivers keys, mouse events, pastes and resizes through the
    run loop's input dispatch, renders a change made through a binding or an
    observable model with render(), and reads each presented frame as a
    RasterSurface or as lines of text. Nothing sleeps and nothing reads the
    wall clock. It drives the synchronous frame path; the asynchronous render
    modes and .task work are outside it. The new DocC article
    Driving-The-Run-Loop is the guide, and the external transition consumer
    fixture now tests two of its demonstrations on the run loop (STUI-1571).

Fixed

  • A custom Transition on content that emits several views (a Group, a
    ForEach, a view whose body has several roots) no longer draws the views
    on top of each other. The transition now applies to each view, as in
    SwiftUI: its body is evaluated once for each view, and each view takes the
    place in its container that it takes without the transition and is
    inserted and removed by itself. A body that places content twice, or
    puts it inside a view of its own, therefore does so for each view
    (STUI-1574).
  • A view under a custom Transition keeps its layout role. Its container
    reads the view's layout priority, fixed size, spacing, alignment guides,
    text baselines and layout values through the body, and a Spacer under a
    custom transition expands (STUI-1575).
  • A view with a transition inside another view with a transition no longer
    plans a removal of its own when the outer view leaves. The second removal
    drew the departing view twice and, depending on the order of a set, ended
    the animations of the outer view's Transition body. One removal now plays
    for each view that leaves, and the removals of a frame are planned in a
    fixed order (STUI-1576).
  • A shape that conforms to Animatable now draws a change to a field outside
    its animatableData while the data animates. The animation in flight kept
    the shape it started with until it ended (STUI-1577).
  • An app with a view under .transition(_:) no longer wakes about 30 times a
    second while nothing animates. A transition that was only registered, with
    no insertion or removal in flight, kept a frame armed every 33 ms for as
    long as its view was in the scene, visible or not. The run loop now sleeps
    until something asks for a frame: an input, a state change, a signal or a
    timer. An insertion and a removal still start on the frame their view
    appears or leaves (STUI-1547).
  • The run loop no longer goes to sleep with a frame deadline that is due. A
    deadline that came due in the few microseconds between the last frame of a
    turn of the run loop and its decision to wait got no wake, when nothing in
    that turn had asked for a frame. Its frame waited for the next input, state
    change or signal. Several deadlines close together made this likely: the
    ones a task leaves behind when it writes state while an animation plays.
    Any frame deadline could wait this way, a long-press timer for example. The
    run loop now decides whether to wait with one reading of the clock, and
    starts its next turn at once when a frame is ready at that reading. During
    a terminal handoff it waits, and the end of the handoff wakes it, also when
    the terminal could not be given back (STUI-1585).