perf(runtime): build and sync layouts with fewer allocations (#15378)

* fix(runtime): list a layout's style among its children once

A layout's style names the layout as its parent, so the style's own
onAddedDirty already adds it to the layout's children. The layout's
onAddedDirty then added it again, so the runtime listed every layout's
style twice and every walk over a layout's children visited it twice.
The editor build dedupes children, so it never showed. The layout now
adds the style only when the style is parented somewhere else.

In the HUD perf tray, 359 of the 3,227 children added at load were
these duplicates, and an added leaderboard row makes 2 fewer
allocations.

Two state machine tests picked shapes by their position among the
artboard's children, a count that included the duplicate; they now find
the shapes by name. The test that an instance's child list is sized
exactly used a row whose three children counted the duplicate, so it now
uses a row that still has three.

* perf(runtime): keep a layout item's style appliers inline

Every layout item lists the objects that apply its style: the item
itself, its style and, under a grid, its placement. The list was a lazy
heap vector, so a layout component allocated the vector, then a buffer
for one applier, then grew it for the second and again for a placement.
The first three appliers now live inline in LayoutData, and only a
fourth moves the list to the heap.

LayoutData grows from 728 to 752 bytes, and each layout item drops a
vector and its buffer from the heap (48 to 64 bytes). In the HUD perf
tray, an added leaderboard row makes 18 fewer allocations.

* perf(runtime): leave Yoga's grid properties unallocated on flex layouts

Yoga keeps a node's grid tracks and lines in a box it allocates on the
first write, so a node that isn't a grid never pays for them. Every
layout that isn't a stack still wrote its four track lists on each style
sync, empty or not, which allocated that box for every flex layout. The
lists are now written only when the layout has tracks, or old ones to
clear.

In the HUD perf tray, an added leaderboard row makes 5 fewer allocations,
and each flex layout drops its unused grid box from the heap.

* perf(runtime): size a layout's background path once

Path::addRoundedRect built a layout's background a verb and a point at a
time, so its arrays grew several times on the first build. It now
reserves the outline's exact size first: a move, four lines and a close,
plus a cubic for each rounded corner.

In the HUD perf tray, an added leaderboard row makes 6 fewer
allocations.

* perf(runtime): list an artboard's dirty layouts in a vector

An artboard kept the layouts whose style changed in an unordered_set, so
marking a layout allocated a node, and a busy set its buckets too. They
are now a vector in the order they were marked, and each layout says it
is listed: a layout in a spare bit of its flags, and an artboard listed
by its host in a bool, since an artboard can be listed by its host and by
itself at once. Both sit in existing padding, and Artboard shrinks from
1096 to 1080 bytes.

An artboard now leaves its own and its host's lists in ~Artboard, while
it is still whole. ~LayoutComponent used to do that for it, after
Artboard's members, the list among them, were already destroyed. An
artboard moving to another host also leaves the old host's list.

The editor moves a component to another artboard by setting its artboard
directly, and clears it that way before it frees or orphans one. A layout
moving that way leaves the old artboard's list first, and so do the
artboards a host moving that way lays out, a list's pooled rows among
them. Otherwise a moved one's flag would stay set, so the new artboard
would never list it, and a freed one would stay listed for the next sync
to read. Deleting a listed layout in the editor did that before this
change too: its destructor leaves the list through its artboard, which
the editor had already cleared.

In the HUD perf tray, an added leaderboard row makes 4 fewer allocations.

* perf(runtime): keep Yoga's child list when a layout's children didn't change

syncLayoutChildren removed every child from the layout's Yoga node,
which also freed the node's child list, and then added the children back
one at a time, growing a fresh list and a scratch list on every sync. A
sync now collects the children first, into a scratch list sized for the
ones the node had. When they are the same children in the same order, it
resets them as removing and adding them again would and keeps Yoga's
list as it is.

The children's layouts are still reset and the node is still marked
dirty, so a layout solves exactly as before.

In the HUD perf tray, an added leaderboard row makes 3 fewer
allocations, all in the root re-sync that hosting the row does.

* perf(runtime): host list rows without syncing the host's root layout

Hosting an artboard that shares its host's layout synced the layout
children of the artboard holding the host, its root, once per artboard.
A component list syncs its own layout parent once its rows are in place,
which is the layout that actually holds them and may not be the root, so
adding N rows synced the root N times for nothing: each sync collected
the root's children again and reset their Yoga layouts. A host now says
whether it syncs its layout parent itself, and the list does.

Nested artboard layouts still sync the root when they mount an artboard.

In the HUD perf tray, adding 400 leaderboard rows no longer syncs the
hud_race artboard's root layout 400 times, and makes 1 fewer allocation
per row.

* perf(runtime): tell whether a list shows a row's artboard without scanning

Every time a row's layout changed, the list checked that the row's
artboard was showing by scanning all its realized rows, so adding N rows,
each marking its layout dirty several times while it set up, cost O(N^2).
Putting an artboard in a row now tells it the row, and the list checks
that one row first. Without repeated items an artboard sits in one row at
most, the last it was put in, so a row that no longer holds it means none
does. A list that repeats items still scans when that row doesn't match.

The row sits in Artboard's padding, so Artboard stays 1080 bytes.

With the seven commits before it (CLI bench, M2 Max): in the HUD perf
tray an added leaderboard row makes 39 fewer allocations (707.7 to
668.7) and a lap time row 45 fewer, and Discord clone server and channel
switches allocate 2 to 6% less. Adding 400 leaderboard rows
measures 5.7% faster, 100 rows 7.8% and 100 lap time rows 8.4%; removing
rows and idle frames are unchanged within noise. Pixels match at all 69
bench checkpoints of the HUD, Discord clone and calendar trays.

* perf(runtime): tell a hosted artboard from a dirty layout without a virtual call

Marking a layout dirty asks whether it's an artboard its host listed, and
is<Artboard>() answered that with a virtual call on every mark. A state
machine that keys layout properties many times a frame stalled on it: since
the dirty layouts became a vector, one UAT corpus file (29581) ran 7% more
cycles per frame on fewer instructions. An artboard is its own artboard(),
so comparing that answers without the call.

In 29581, a steady frame takes 1.24 ms instead of 1.35 ms, and 18.9M
instead of 19.7M instructions (1.30 ms and 20.5M before this branch). The
corpus draws the same frames and makes the same allocations.

Rive-Mono-Commit: 4ca5e1e3e77075460ed1f466d6c09cc94cb9ea4f
diff --git a/include/rive/artboard.hpp b/include/rive/artboard.hpp
index 52f67fe..23854c3 100644
--- a/include/rive/artboard.hpp
+++ b/include/rive/artboard.hpp
@@ -189,11 +189,22 @@
   bool m_FrameOrigin = true;
   // In the padding after the flags above; see quietHostRow.
   uint32_t m_quietHostRow = kNoQuietRow;
-  std::unordered_set<LayoutComponent*> m_dirtyLayout;
+  // Layouts whose style changed since the last sync, each once, in the order
+  // they were marked. Each says it's listed: a layout in its flags, and an
+  // artboard listed by its host in m_listedInHostDirtyLayout, as an artboard
+  // can be listed by its host and by itself at once.
+  std::vector<LayoutComponent*> m_dirtyLayout;
   bool m_isCleaningDirtyLayouts = false;
   // Set by an adoptFocusManager that left the tree to the host, cleared by the
   // next buildFocusTree. Sits in padding.
   bool m_focusTreeDeferred = false;
+  // In the padding too; see m_dirtyLayout.
+  bool m_listedInHostDirtyLayout = false;
+  // In the padding too; see listRow.
+  uint32_t m_listRow = kNoQuietRow;
+  bool listedAsDirty(LayoutComponent* layout);
+  void listedAsDirty(LayoutComponent* layout, bool value);
+  void leaveDirtyLayouts();
   std::unique_ptr<KeyFrameInterpolator> m_ownedInheritedInterpolator;
   // Live clones of the scripted interpolators this instance's layout styles
   // use. Allocated on first use; see statefulInterpolator().
@@ -390,6 +401,11 @@
   static constexpr uint32_t kNoQuietRow = 0xFFFFFFFF;
   uint32_t quietHostRow() const { return m_quietHostRow; }
   void quietHostRow(uint32_t row) { m_quietHostRow = row; }
+  /// The row of its host list this artboard was last put in, kNoQuietRow
+  /// before any. The list may have moved it out since; see
+  /// ArtboardComponentList::showsInARow.
+  uint32_t listRow() const { return m_listRow; }
+  void listRow(uint32_t row) { m_listRow = row; }
   void wakeIfQuietRow()
   {
     if (m_quietHostRow != kNoQuietRow)
diff --git a/include/rive/artboard_component_list.hpp b/include/rive/artboard_component_list.hpp
index 76e8e43..5594553 100644
--- a/include/rive/artboard_component_list.hpp
+++ b/include/rive/artboard_component_list.hpp
@@ -44,6 +44,9 @@
 public:
 #ifdef WITH_RIVE_EDITOR
   void editorPrepareForDestruction() override;
+  // The pooled rows too: they keep the list as their host.
+  void forEachHostedArtboard(
+      const std::function<void(ArtboardInstance*)>& visit) override;
 #endif
   ArtboardComponentList();
   ~ArtboardComponentList() override;
@@ -116,6 +119,9 @@
 #endif
   void markLayoutNodeDirty(bool shouldForceUpdateLayoutBounds = false) override;
   bool isLayoutProvider() override { return true; }
+  // updateList syncs once all its rows are in, and a row realized on its own
+  // syncs once it's findable by its index.
+  bool syncsLayoutChildren() override { return true; }
   size_t numLayoutNodes() override { return m_listItems.size(); }
 #ifdef WITH_RIVE_LAYOUT
   void collectLayoutNodes(std::vector<void*>& out) override;
@@ -246,6 +252,10 @@
   // the maps above, which own the instances, so per-row loops can reach a
   // row without hashing its item.
   std::vector<ArtboardInstance*> m_artboardInstancesByIndex;
+  // Sets a row's instance, and tells the instance its row.
+  void placeInRow(size_t index, ArtboardInstance* artboard);
+  // Whether a realized row holds artboard.
+  bool showsInARow(ArtboardInstance* artboard);
   std::vector<StateMachineInstance*> m_stateMachinesByIndex;
   // Points the row at index, and any other row showing the same item, at
   // the item's instances.
@@ -359,6 +369,8 @@
 public:
   // Row passes skipped because the row was quiet, across every list.
   static uint64_t sm_quietRowSkips;
+  // Rows scanned for an artboard because the list repeats items.
+  static uint32_t sm_rowScans;
   // Lets a test run the same frames with and without quiet rows.
   static bool sm_quietRowsEnabled;
   // Lets a benchmark time quiet rows without checking each one every pass.
diff --git a/include/rive/artboard_host.hpp b/include/rive/artboard_host.hpp
index 4241479..6827392 100644
--- a/include/rive/artboard_host.hpp
+++ b/include/rive/artboard_host.hpp
@@ -5,6 +5,9 @@
 #include "rive/data_bind_path_referencer.hpp"
 #include "rive/math/mat2d.hpp"
 #include <stdio.h>
+#ifdef WITH_RIVE_EDITOR
+#include <functional>
+#endif
 namespace rive
 {
 class ArtboardInstance;
@@ -17,6 +20,20 @@
 public:
   virtual size_t artboardCount() = 0;
   virtual ArtboardInstance* artboardInstance(int index = 0) = 0;
+#ifdef WITH_RIVE_EDITOR
+  /// Every artboard the host owns, including any it keeps but doesn't show.
+  virtual void forEachHostedArtboard(
+      const std::function<void(ArtboardInstance*)>& visit)
+  {
+    for (size_t i = 0, count = artboardCount(); i < count; i++)
+    {
+      if (ArtboardInstance* hosted = artboardInstance((int)i))
+      {
+        visit(hosted);
+      }
+    }
+  }
+#endif
   virtual void internalDataContext(rcp<DataContext> dataContext) = 0;
   virtual void bindViewModelInstance(
       rcp<ViewModelInstance> viewModelInstance,
@@ -41,6 +58,9 @@
   virtual Mat2D worldTransformForArtboard(ArtboardInstance*) = 0;
   virtual void markHostTransformDirty() = 0;
   virtual bool isLayoutProvider() { return false; }
+  // Whether the host syncs its layout parent's children itself once the
+  // artboards it hosts are in place, so hosting one needn't sync them.
+  virtual bool syncsLayoutChildren() { return false; }
   virtual void file(File* value) = 0;
   virtual File* file() const = 0;
   /// The file the hosted artboard was bound in from, when it isn't file().
diff --git a/include/rive/component.hpp b/include/rive/component.hpp
index 4e5d95e..49f866a 100644
--- a/include/rive/component.hpp
+++ b/include/rive/component.hpp
@@ -248,8 +248,10 @@
   /// silently breaking dirt propagation into the artboard's
   /// component pass.
   /// `EditorFile::finalizeBatch` calls this after every Pass 1-5
-  /// completes, when the parent chain is fully hydrated.
-  void setArtboardForEditor(Artboard* ab) { m_Artboard = ab; }
+  /// completes, when the parent chain is fully hydrated. A layout moving
+  /// to another artboard, or to none, leaves the old one's dirty layouts,
+  /// and so do the artboards a host moving that way lays out.
+  void setArtboardForEditor(Artboard* ab);
   // Body in `editor_native/native/src/editor/component_editor.cpp`.
   // Resolves through `editorArena()` to convert pointer ↔ handle.
   void setParentForEditor(ContainerComponent* p);
diff --git a/include/rive/layout/layout_data.hpp b/include/rive/layout/layout_data.hpp
index ff3f078..2a3a5dd 100644
--- a/include/rive/layout/layout_data.hpp
+++ b/include/rive/layout/layout_data.hpp
@@ -3,10 +3,12 @@
 
 #ifdef WITH_RIVE_LAYOUT
 #include "rive/layout/layout_style_applier.hpp"
-#include "rive/lazy_vector.hpp"
 #include "yoga/YGNode.h"
 #include "yoga/YGStyle.h"
 #include "yoga/Yoga.h"
+#include <algorithm>
+#include <cstdint>
+#include <vector>
 #endif
 #ifdef WITH_RIVE_TOOLS
 #include "rive/refcnt.hpp"
@@ -16,6 +18,66 @@
 
 namespace rive
 {
+#ifdef WITH_RIVE_LAYOUT
+/// The appliers of one layout item: the item itself, its style and its grid
+/// placement. Up to three live inline, so an item allocates nothing for them;
+/// a fourth moves the list to the heap.
+class LayoutStyleApplierList
+{
+public:
+  LayoutStyleApplierList() = default;
+  ~LayoutStyleApplierList()
+  {
+    if (spilled())
+    {
+      delete m_spill;
+    }
+  }
+  LayoutStyleApplierList(const LayoutStyleApplierList&) = delete;
+  LayoutStyleApplierList& operator=(const LayoutStyleApplierList&) = delete;
+
+  bool empty() const { return m_size == 0; }
+  std::size_t size() const { return m_size; }
+  LayoutStyleApplier* const* begin() const
+  {
+    return spilled() ? m_spill->data() : m_inline;
+  }
+  LayoutStyleApplier* const* end() const { return begin() + m_size; }
+
+  void pushUnique(LayoutStyleApplier* applier)
+  {
+    if (std::find(begin(), end(), applier) != end())
+    {
+      return;
+    }
+    if (m_size < kInline)
+    {
+      m_inline[m_size++] = applier;
+      return;
+    }
+    if (m_size == kInline)
+    {
+      m_spill = new std::vector<LayoutStyleApplier*>(
+          m_inline,
+          m_inline + kInline);
+    }
+    m_spill->push_back(applier);
+    m_size++;
+  }
+
+private:
+  static constexpr uint32_t kInline = 3;
+  bool spilled() const { return m_size > kInline; }
+
+  union
+  {
+    LayoutStyleApplier* m_inline[kInline] = {};
+    std::vector<LayoutStyleApplier*>* m_spill;
+  };
+  uint32_t m_size = 0;
+};
+#endif
+
 class LayoutData
 #ifdef WITH_RIVE_TOOLS
     : public RefCnt<LayoutData>
@@ -68,10 +130,9 @@
   YGStyle& style() { return node.getStyle(); }
   const YGStyle& style() const { return node.getStyle(); }
 
-  /// Objects contributing to this item's style. Lazy, so an item with none
-  /// pays one null pointer. Unsorted — apply order comes from the phase
-  /// methods, not from list order, which follows file order.
-  LazyVector<LayoutStyleApplier*> appliers;
+  /// Objects contributing to this item's style. Unsorted — apply order comes
+  /// from the phase methods, not from list order, which follows file order.
+  LayoutStyleApplierList appliers;
 
   /// No matching remove: runtime objects live for the artboard's lifetime.
   void addApplier(LayoutStyleApplier* applier) { appliers.pushUnique(applier); }
diff --git a/include/rive/layout_component.hpp b/include/rive/layout_component.hpp
index 7651c00..c6a2fad 100644
--- a/include/rive/layout_component.hpp
+++ b/include/rive/layout_component.hpp
@@ -75,6 +75,9 @@
   // it from the style chases a pointer each time. Refreshed wherever the
   // style or its display changes (see refreshStyleDisplayHidden).
   StyleDisplayHidden = 1 << 14,
+  // Listed in its artboard's dirty layouts (see Artboard::markLayoutDirty), so
+  // marking it again doesn't list it twice.
+  DirtyLayoutListed = 1 << 15,
 };
 
 class Layout
@@ -357,6 +360,16 @@
   StatusCode import(ImportStack& importStack) override;
   Core* clone() const override;
 
+  // Only the artboard listing this layout as dirty sets it.
+  bool dirtyLayoutListed() const
+  {
+    return hasLayoutFlag(LayoutComponentFlags::DirtyLayoutListed);
+  }
+  void dirtyLayoutListed(bool value)
+  {
+    setLayoutFlag(LayoutComponentFlags::DirtyLayoutListed, value);
+  }
+
   LayoutComponentStyle* style() { return m_style; }
   void style(LayoutComponentStyle* style)
   {
@@ -587,6 +600,13 @@
   void* layoutNode(int index) override;
   void syncStyle();
   void syncLayoutChildren();
+#ifdef TESTING
+  // Syncs that found the children changed and rebuilt Yoga's list.
+  static uint32_t sm_layoutChildRebuilds;
+  // Counts the syncs of one layout, when set.
+  static LayoutComponent* sm_countSyncsOf;
+  static uint32_t sm_countedSyncs;
+#endif
   void clearLayoutChildren();
   virtual void propagateSize();
   void updateLayoutBounds(bool animate = true) override;
diff --git a/src/artboard.cpp b/src/artboard.cpp
index b91b9ab..3b76e71 100644
--- a/src/artboard.cpp
+++ b/src/artboard.cpp
@@ -303,7 +303,7 @@
       delete object;
     }
   }
-  m_dirtyLayout.clear();
+  leaveDirtyLayouts();
 }
 
 static bool canContinue(StatusCode code)
@@ -2109,6 +2109,13 @@
 void Artboard::host(ArtboardHost* artboardHost)
 {
   addedToHost();
+  if (m_listedInHostDirtyLayout && artboardHost != m_host)
+  {
+    if (Artboard* parent = parentArtboard())
+    {
+      parent->cleanLayout(this);
+    }
+  }
   m_host = artboardHost;
 #ifdef EXTERNAL_RIVE_AUDIO_ENGINE
   // audioEngine(engine) only reaches artboards hosted at the time, so list
@@ -2131,7 +2138,10 @@
   if (parent != nullptr)
   {
     parent->markLayoutDirty(this);
-    parent->syncLayoutChildren();
+    if (!m_host->syncsLayoutChildren())
+    {
+      parent->syncLayoutChildren();
+    }
   }
 #endif
 }
@@ -2430,9 +2440,13 @@
     return;
   }
 
-  if (!m_dirtyLayout.empty())
+  if (listedAsDirty(layoutComponent))
   {
-    auto itr = m_dirtyLayout.find(layoutComponent);
+    listedAsDirty(layoutComponent, false);
+    auto itr = std::find(
+        m_dirtyLayout.begin(),
+        m_dirtyLayout.end(),
+        layoutComponent);
     if (itr != m_dirtyLayout.end())
     {
       m_dirtyLayout.erase(itr);
@@ -2450,6 +2464,58 @@
   }
 }
 
+// An artboard is its own artboard(). Reading that tells a hosted artboard
+// from a layout without is<Artboard>(), a virtual call, which every mark
+// would make.
+static bool isHostedArtboard(const Artboard* host, LayoutComponent* layout)
+{
+  return layout != host && layout->artboard() == layout;
+}
+
+// An artboard can be listed by its host and by itself at once, so one listed
+// by its host says so on itself rather than in its layout flags.
+bool Artboard::listedAsDirty(LayoutComponent* layout)
+{
+  if (isHostedArtboard(this, layout))
+  {
+    return static_cast<Artboard*>(layout)->m_listedInHostDirtyLayout;
+  }
+  return layout->dirtyLayoutListed();
+}
+
+void Artboard::listedAsDirty(LayoutComponent* layout, bool value)
+{
+  if (isHostedArtboard(this, layout))
+  {
+    static_cast<Artboard*>(layout)->m_listedInHostDirtyLayout = value;
+  }
+  else
+  {
+    layout->dirtyLayoutListed(value);
+  }
+}
+
+// Called while the artboard is still whole: ~LayoutComponent skips an artboard,
+// whose list is gone by then. The layouts it owned left as they were deleted.
+void Artboard::leaveDirtyLayouts()
+{
+  if (m_listedInHostDirtyLayout)
+  {
+    if (Artboard* parent = parentArtboard())
+    {
+      parent->cleanLayout(this);
+    }
+  }
+  for (auto* layout : m_dirtyLayout)
+  {
+    if (layout != nullptr)
+    {
+      listedAsDirty(layout, false);
+    }
+  }
+  m_dirtyLayout.clear();
+}
+
 void Artboard::markLayoutDirty(LayoutComponent* layoutComponent)
 {
   wakeIfQuietRow();
@@ -2468,7 +2534,11 @@
     m_layoutDirtyCallback(callbackUserData);
   }
 #endif
-  m_dirtyLayout.insert(layoutComponent);
+  if (!listedAsDirty(layoutComponent))
+  {
+    listedAsDirty(layoutComponent, true);
+    m_dirtyLayout.push_back(layoutComponent);
+  }
   if (isInstance())
   {
     if (sharesLayoutWithHost())
@@ -2524,6 +2594,7 @@
       {
         continue;
       }
+      listedAsDirty(layout, false);
       switch (layout->coreType())
       {
         case ArtboardBase::typeKey:
@@ -5433,7 +5504,7 @@
   m_DrawTargets.clear();
   m_Joysticks.clear();
   m_advancingComponents.clear();
-  m_dirtyLayout.clear();
+  leaveDirtyLayouts();
   m_host = nullptr;
   m_DependencyOrder.clear();
   m_editorResolver = nullptr;
diff --git a/src/artboard_component_list.cpp b/src/artboard_component_list.cpp
index 8629ac9..08adba1 100644
--- a/src/artboard_component_list.cpp
+++ b/src/artboard_component_list.cpp
@@ -222,7 +222,7 @@
         m_listItems[index] == item)
     {
       resetQuietRow(index);
-      m_artboardInstancesByIndex[index] = artboard;
+      placeInRow(index, artboard);
       m_stateMachinesByIndex[index] = stateMachine;
       markRealized(index, artboard != nullptr);
     }
@@ -233,7 +233,7 @@
     if (m_listItems[i] == item)
     {
       resetQuietRow(i);
-      m_artboardInstancesByIndex[i] = artboard;
+      placeInRow(i, artboard);
       m_stateMachinesByIndex[i] = stateMachine;
       markRealized(i, artboard != nullptr);
     }
@@ -1091,7 +1091,7 @@
     {
       // Existing artboard - update index vectors
       resetQuietRow(index);
-      m_artboardInstancesByIndex[index] = itr->second.get();
+      placeInRow(index, itr->second.get());
       markRealized(index, itr->second != nullptr);
       auto smItr = m_stateMachinesMap.find(item);
       if (smItr != m_stateMachinesMap.end())
@@ -1597,18 +1597,49 @@
   return AABB();
 }
 
+#ifdef TESTING
+uint32_t ArtboardComponentList::sm_rowScans = 0;
+#endif
+
+void ArtboardComponentList::placeInRow(size_t index, ArtboardInstance* artboard)
+{
+  m_artboardInstancesByIndex[index] = artboard;
+  if (artboard != nullptr)
+  {
+    artboard->listRow((uint32_t)index);
+  }
+}
+
+bool ArtboardComponentList::showsInARow(ArtboardInstance* artboard)
+{
+  // Putting an artboard in a row tells it the row. Without repeated items an
+  // artboard is in one row at most, the last one it was put in, so a row
+  // that no longer holds it means none does.
+  uint32_t row = artboard->listRow();
+  if (row < m_artboardInstancesByIndex.size() &&
+      m_artboardInstancesByIndex[row] == artboard)
+  {
+    return true;
+  }
+  if (!m_listHasDuplicateItems)
+  {
+    return false;
+  }
+#ifdef TESTING
+  sm_rowScans++;
+#endif
+  return std::any_of(
+      m_realizedIndices.begin(),
+      m_realizedIndices.end(),
+      [&](int i) { return m_artboardInstancesByIndex[i] == artboard; });
+}
+
 void ArtboardComponentList::markHostingLayoutDirty(
     ArtboardInstance* artboardInstance)
 {
   // Only an artboard showing in a row joins the parent's layout. Artboards
   // in the pools get here too, whenever reusing one resets its properties.
-  if (artboardInstance != nullptr &&
-      std::any_of(
-          m_realizedIndices.begin(),
-          m_realizedIndices.end(),
-          [&](int i) {
-            return m_artboardInstancesByIndex[i] == artboardInstance;
-          }))
+  if (artboardInstance != nullptr && showsInARow(artboardInstance))
   {
     this->artboard()->markLayoutDirty(artboardInstance);
   }
@@ -2225,7 +2256,7 @@
       // updateList builds a non-virtualized list's rows in order and
       // gives an item's later rows the instances made for its first.
       resetQuietRow(index);
-      m_artboardInstancesByIndex[index] = artboardInstance;
+      placeInRow(index, artboardInstance);
       m_stateMachinesByIndex[index] = stateMachineInstance;
       markRealized(index, artboardInstance != nullptr);
     }
@@ -2706,4 +2737,26 @@
   Component::editorPrepareForDestruction();
 }
 
+void ArtboardComponentList::forEachHostedArtboard(
+    const std::function<void(ArtboardInstance*)>& visit)
+{
+  for (auto& item : m_artboardInstancesMap)
+  {
+    if (item.second != nullptr)
+    {
+      visit(item.second.get());
+    }
+  }
+  for (auto& pool : m_rowPool)
+  {
+    for (auto& row : pool.second)
+    {
+      if (row.artboard != nullptr)
+      {
+        visit(row.artboard.get());
+      }
+    }
+  }
+}
+
 #endif
diff --git a/src/component.cpp b/src/component.cpp
index abad78e..79e9392 100644
--- a/src/component.cpp
+++ b/src/component.cpp
@@ -2,6 +2,8 @@
 #ifdef WITH_RIVE_EDITOR
 #include "rive/scripted/scripted_object.hpp"
 #include "rive/focus_data.hpp"
+#include "rive/artboard_component_list.hpp"
+#include "rive/nested_artboard.hpp"
 #endif
 #include "rive/artboard.hpp"
 #include "rive/container_component.hpp"
@@ -189,6 +191,44 @@
     m_Artboard->collapseChanged();
   }
 }
+
+void Component::setArtboardForEditor(Artboard* ab)
+{
+  // A layout says in its flags that it's listed as dirty, and so does an
+  // artboard its host lays out. Left in the old artboard's list, it would
+  // keep saying so, and the new artboard would never list it; leaving no
+  // artboard, it would be freed still listed, as a host's artboard can't
+  // find the list without the host's. Only a listed one reaches the old
+  // artboard, which unlists its layouts if it goes first.
+  if (m_Artboard != nullptr && m_Artboard != ab && m_Artboard != this)
+  {
+    if (is<LayoutComponent>() && as<LayoutComponent>()->dirtyLayoutListed())
+    {
+      m_Artboard->cleanLayout(as<LayoutComponent>());
+    }
+    ArtboardHost* host = nullptr;
+    if (is<NestedArtboard>())
+    {
+      host = as<NestedArtboard>();
+    }
+    else if (is<ArtboardComponentList>())
+    {
+      host = as<ArtboardComponentList>();
+    }
+    if (host != nullptr)
+    {
+      Artboard* old = m_Artboard;
+      host->forEachHostedArtboard([old](ArtboardInstance* instance) {
+        Artboard* hosted = instance;
+        if (hosted->m_listedInHostDirtyLayout)
+        {
+          old->cleanLayout(hosted);
+        }
+      });
+    }
+  }
+  m_Artboard = ab;
+}
 #endif
 
 bool Component::hitTestPoint(
diff --git a/src/layout/grid_track.cpp b/src/layout/grid_track.cpp
index abe46da..0aef87a 100644
--- a/src/layout/grid_track.cpp
+++ b/src/layout/grid_track.cpp
@@ -110,10 +110,18 @@
     }
     lists[track->collection()].push_back(gridTrackSize(track));
   }
-  ygStyle.setGridTemplateColumns(std::move(lists[0]));
-  ygStyle.setGridTemplateRows(std::move(lists[1]));
-  ygStyle.setGridAutoColumns(std::move(lists[2]));
-  ygStyle.setGridAutoRows(std::move(lists[3]));
+  // Yoga allocates the track lists on their first write, so a layout with no
+  // tracks, such as any flex layout, writes them only to clear old ones.
+  if (!lists[0].empty() || !lists[1].empty() || !lists[2].empty() ||
+      !lists[3].empty() || !ygStyle.gridTemplateColumns().empty() ||
+      !ygStyle.gridTemplateRows().empty() ||
+      !ygStyle.gridAutoColumns().empty() || !ygStyle.gridAutoRows().empty())
+  {
+    ygStyle.setGridTemplateColumns(std::move(lists[0]));
+    ygStyle.setGridTemplateRows(std::move(lists[1]));
+    ygStyle.setGridAutoColumns(std::move(lists[2]));
+    ygStyle.setGridAutoRows(std::move(lists[3]));
+  }
   ygStyle.setJustifyItems((YGJustify)justifyItemsValue);
 }
 
diff --git a/src/layout_component.cpp b/src/layout_component.cpp
index 852b104..12c8db0 100644
--- a/src/layout_component.cpp
+++ b/src/layout_component.cpp
@@ -26,6 +26,7 @@
 #include "yoga/YGEnums.h"
 #include "yoga/YGFloatOptional.h"
 #endif
+#include <algorithm>
 #include <vector>
 
 using namespace rive;
@@ -728,7 +729,12 @@
     return StatusCode::MissingObject;
   }
   m_style = static_cast<LayoutComponentStyle*>(coreStyle);
-  addChild(m_style);
+  // A style that names us as its parent joins our children on its own, so
+  // adding it here too would list it twice.
+  if (context->resolve(m_style->parentId()) != this)
+  {
+    addChild(m_style);
+  }
 #ifdef WITH_RIVE_LAYOUT
   refreshStyleDisplayHidden();
   // We contribute sizing the style cannot see; it contributes the rest.
@@ -1436,24 +1442,62 @@
   YGNodeRemoveAllChildren(&ourNode);
 }
 
+#ifdef TESTING
+uint32_t LayoutComponent::sm_layoutChildRebuilds = 0;
+LayoutComponent* LayoutComponent::sm_countSyncsOf = nullptr;
+uint32_t LayoutComponent::sm_countedSyncs = 0;
+#endif
+
 void LayoutComponent::syncLayoutChildren()
 {
+#ifdef TESTING
+  if (this == sm_countSyncsOf)
+  {
+    sm_countedSyncs++;
+  }
+#endif
   YGNode& ourNode = m_layoutData->node;
-  YGNodeRemoveAllChildren(&ourNode);
   std::vector<void*> nodes;
+  // A sync mostly finds the children it had, so this usually fits them.
+  nodes.reserve(ourNode.getChildren().size());
   forEachLayoutProvider(
       this,
       [&nodes](Component*, LayoutNodeProvider* provider) {
         provider->collectLayoutNodes(nodes);
       });
-  int index = 0;
-  for (auto* node : nodes)
+  const auto& children = ourNode.getChildren();
+  if (!children.empty() && nodes.size() == children.size() &&
+      std::equal(nodes.begin(), nodes.end(), children.begin()))
   {
-    auto* child = static_cast<YGNode*>(node);
-    ourNode.insertChild(child, index++);
-    child->setOwner(&ourNode);
+    // The same children in the same order: reset them as removing and adding
+    // them again would, but keep Yoga's list instead of freeing and regrowing
+    // it.
+    const bool owned = children.front()->getOwner() == &ourNode;
+    for (auto* child : children)
+    {
+      if (owned)
+      {
+        child->setLayout(YGNode().getLayout());
+      }
+      child->setOwner(&ourNode);
+    }
     ourNode.markDirtyAndPropagate();
   }
+  else
+  {
+#ifdef TESTING
+    sm_layoutChildRebuilds++;
+#endif
+    YGNodeRemoveAllChildren(&ourNode);
+    int index = 0;
+    for (auto* node : nodes)
+    {
+      auto* child = static_cast<YGNode*>(node);
+      ourNode.insertChild(child, index++);
+      child->setOwner(&ourNode);
+      ourNode.markDirtyAndPropagate();
+    }
+  }
   markLayoutNodeDirty();
 }
 
@@ -2267,7 +2311,8 @@
 LayoutComponent::~LayoutComponent()
 {
   delete m_virtualGrid;
-  if (artboard() != nullptr)
+  // An artboard leaves the dirty layouts in ~Artboard, while it's still whole.
+  if (artboard() != nullptr && artboard() != this)
   {
     artboard()->cleanLayout(this);
   }
diff --git a/src/shapes/path.cpp b/src/shapes/path.cpp
index 7768384..44a8fad 100644
--- a/src/shapes/path.cpp
+++ b/src/shapes/path.cpp
@@ -184,6 +184,18 @@
   // limit.
   const float maxRadius = std::min(bounds.width(), bounds.height()) * 0.5f;
 
+  // Room for the whole outline at once: a move, a line into each other corner,
+  // a line back to the start and a close, plus a cubic for each rounded
+  // corner.
+  size_t rounded = 0;
+  for (const Corner& corner : corners)
+  {
+    rounded += corner.radius != 0.0f ? 1 : 0;
+  }
+  rawPath.reserve(
+      rawPath.verbs().size() + 6 + rounded,
+      rawPath.points().size() + 5 + 3 * rounded);
+
   Vec2D start;
   for (int i = 0; i < 4; i++)
   {
diff --git a/tests/unit_tests/runtime/component_list_test.cpp b/tests/unit_tests/runtime/component_list_test.cpp
index c4ecd05..991c220 100644
--- a/tests/unit_tests/runtime/component_list_test.cpp
+++ b/tests/unit_tests/runtime/component_list_test.cpp
@@ -2062,6 +2062,158 @@
   }
 }
 
+// A row's layout changing lists the row as dirty in the row and in the host
+// artboard, which syncs the row's list when it syncs its own.
+TEST_CASE(
+    "Component List rows are listed as dirty by the row and the host",
+    "[component_list]")
+{
+  auto file = ReadRiveFile("assets/component_list_rtl_row.riv");
+  auto artboard = file->artboardNamed("Host");
+  REQUIRE(artboard != nullptr);
+  auto viewModelInstance = file->createDefaultViewModelInstance(artboard.get());
+  REQUIRE(viewModelInstance != nullptr);
+  artboard->bindViewModelInstance(viewModelInstance);
+  auto stateMachine = artboard->stateMachineAt(0);
+  REQUIRE(stateMachine != nullptr);
+  stateMachine->bindViewModelInstance(viewModelInstance);
+  stateMachine->advanceAndApply(0.016f);
+
+  auto list = artboard->find<rive::ArtboardComponentList>("Rows");
+  REQUIRE(list != nullptr);
+  REQUIRE(list->artboardCount() == 1);
+  auto row = list->artboardInstance(0);
+  REQUIRE(row != nullptr);
+  auto group = row->find<rive::LayoutComponent>("Group");
+  REQUIRE(group != nullptr);
+  REQUIRE(!row->hasDirtyLayout());
+  REQUIRE(!artboard->hasDirtyLayout());
+
+  for (int i = 0; i < 2; i++)
+  {
+    group->markLayoutNodeDirty();
+    row->markLayoutDirty(row);
+    CHECK(row->hasDirtyLayout());
+    CHECK(artboard->hasDirtyLayout());
+    stateMachine->advanceAndApply(0.016f);
+    CHECK(!row->hasDirtyLayout());
+    CHECK(!artboard->hasDirtyLayout());
+  }
+
+  // Rows destroyed while listed leave both lists.
+  group->markLayoutNodeDirty();
+  row->markLayoutDirty(row);
+  REQUIRE(artboard->hasDirtyLayout());
+  auto items = viewModelInstance->propertyValue("rows")
+                   ->as<rive::ViewModelInstanceList>();
+  while (!items->listItems().empty())
+  {
+    items->removeItem(items->listItems().back());
+  }
+  stateMachine->advanceAndApply(0.016f);
+  CHECK(list->artboardCount() == 0);
+  CHECK(!artboard->hasDirtyLayout());
+}
+
+// Adding rows syncs the list's layout parent once, after they're all in.
+// Hosting each row used to sync the host artboard's root too.
+TEST_CASE(
+    "Component List adds rows without syncing the host's root per row",
+    "[component_list]")
+{
+  auto file = ReadRiveFile("assets/component_list_rtl_row.riv");
+  auto artboard = file->artboardNamed("Host");
+  REQUIRE(artboard != nullptr);
+  auto viewModelInstance = file->createDefaultViewModelInstance(artboard.get());
+  REQUIRE(viewModelInstance != nullptr);
+  artboard->bindViewModelInstance(viewModelInstance);
+  auto stateMachine = artboard->stateMachineAt(0);
+  REQUIRE(stateMachine != nullptr);
+  stateMachine->bindViewModelInstance(viewModelInstance);
+  stateMachine->advanceAndApply(0.016f);
+
+  auto list = artboard->find<rive::ArtboardComponentList>("Rows");
+  REQUIRE(list != nullptr);
+  auto items = viewModelInstance->propertyValue("rows")
+                   ->as<rive::ViewModelInstanceList>();
+  auto rowViewModel = items->listItems()[0]->viewModelInstance()->viewModel();
+  for (int i = 0; i < 3; i++)
+  {
+    auto item = rive::make_rcp<rive::ViewModelInstanceListItem>();
+    item->viewModelInstance(file->createDefaultViewModelInstance(rowViewModel));
+    items->addItem(item);
+  }
+  rive::LayoutComponent::sm_countSyncsOf = artboard.get();
+  rive::LayoutComponent::sm_countedSyncs = 0;
+  stateMachine->advanceAndApply(0.016f);
+  rive::LayoutComponent::sm_countSyncsOf = nullptr;
+  REQUIRE(list->artboardCount() == 4);
+  CHECK(
+      rive::LayoutComponent::sm_countedSyncs ==
+      (list->layoutParent() == artboard.get() ? 1u : 0u));
+  for (int i = 0; i < 4; i++)
+  {
+    auto row = list->artboardInstance(i);
+    REQUIRE(row != nullptr);
+    CHECK(row->find<rive::LayoutComponent>("A")->layoutX() == 50.0f);
+    CHECK(row->find<rive::LayoutComponent>("B")->layoutX() == 0.0f);
+  }
+}
+
+// A row's artboard knows the row it was put in, so a list without repeated
+// items tells whether it shows the artboard without scanning its rows.
+TEST_CASE(
+    "Component List finds a row's artboard without scanning its rows",
+    "[component_list]")
+{
+  auto file = ReadRiveFile("assets/component_list_rtl_row.riv");
+  auto artboard = file->artboardNamed("Host");
+  REQUIRE(artboard != nullptr);
+  auto viewModelInstance = file->createDefaultViewModelInstance(artboard.get());
+  REQUIRE(viewModelInstance != nullptr);
+  artboard->bindViewModelInstance(viewModelInstance);
+  auto stateMachine = artboard->stateMachineAt(0);
+  REQUIRE(stateMachine != nullptr);
+  stateMachine->bindViewModelInstance(viewModelInstance);
+  stateMachine->advanceAndApply(0.016f);
+
+  auto list = artboard->find<rive::ArtboardComponentList>("Rows");
+  REQUIRE(list != nullptr);
+  auto items = viewModelInstance->propertyValue("rows")
+                   ->as<rive::ViewModelInstanceList>();
+  auto rowViewModel = items->listItems()[0]->viewModelInstance()->viewModel();
+  auto scans = rive::ArtboardComponentList::sm_rowScans;
+  for (int i = 0; i < 3; i++)
+  {
+    auto item = rive::make_rcp<rive::ViewModelInstanceListItem>();
+    item->viewModelInstance(file->createDefaultViewModelInstance(rowViewModel));
+    items->addItem(item);
+  }
+  stateMachine->advanceAndApply(0.016f);
+  REQUIRE(list->artboardCount() == 4);
+  for (int i = 0; i < 4; i++)
+  {
+    REQUIRE(!artboard->hasDirtyLayout());
+    auto row = list->artboardInstance(i);
+    REQUIRE(row != nullptr);
+    row->find<rive::LayoutComponent>("Group")->markLayoutNodeDirty();
+    CHECK(artboard->hasDirtyLayout());
+    stateMachine->advanceAndApply(0.016f);
+  }
+  CHECK(rive::ArtboardComponentList::sm_rowScans == scans);
+
+  // Two rows showing one item share its artboard, and either can mark it.
+  items->addItem(items->listItems()[0]);
+  stateMachine->advanceAndApply(0.016f);
+  REQUIRE(list->artboardCount() == 5);
+  REQUIRE(list->artboardInstance(4) == list->artboardInstance(0));
+  REQUIRE(!artboard->hasDirtyLayout());
+  list->artboardInstance(0)
+      ->find<rive::LayoutComponent>("Group")
+      ->markLayoutNodeDirty();
+  CHECK(artboard->hasDirtyLayout());
+}
+
 // The list's layout is right to left and the row sets no direction, so every
 // row inherits right to left from it. A's left margin then sits on its right,
 // the edge it starts from. A row added after the first frame has to inherit
diff --git a/tests/unit_tests/runtime/instancing_test.cpp b/tests/unit_tests/runtime/instancing_test.cpp
index 358f611..81079c7 100644
--- a/tests/unit_tests/runtime/instancing_test.cpp
+++ b/tests/unit_tests/runtime/instancing_test.cpp
@@ -74,7 +74,7 @@
   // Added one entry at a time, three children grow the list to room for
   // four and twelve dependents to room for sixteen; sized from the source,
   // each holds exactly what it ends up with.
-  auto rowFile = ReadRiveFile("assets/component_list_rtl_row.riv");
+  auto rowFile = ReadRiveFile("assets/component_list_rtl_host.riv");
   auto rowSource = rowFile->artboardNamed("Row");
   REQUIRE(rowSource != nullptr);
   auto row = rowSource->instance();
diff --git a/tests/unit_tests/runtime/layout_style_applier_list_test.cpp b/tests/unit_tests/runtime/layout_style_applier_list_test.cpp
new file mode 100644
index 0000000..20d6806
--- /dev/null
+++ b/tests/unit_tests/runtime/layout_style_applier_list_test.cpp
@@ -0,0 +1,37 @@
+#include "rive/layout/layout_data.hpp"
+#include <catch.hpp>
+#include <vector>
+
+#ifdef WITH_RIVE_LAYOUT
+using namespace rive;
+
+static std::vector<LayoutStyleApplier*> contents(
+    const LayoutStyleApplierList& list)
+{
+  return std::vector<LayoutStyleApplier*>(list.begin(), list.end());
+}
+
+TEST_CASE("Layout style appliers keep their order and skip repeats", "[layout]")
+{
+  LayoutStyleApplier a, b, c, d, e;
+  LayoutStyleApplierList list;
+  CHECK(list.empty());
+  CHECK(contents(list).empty());
+
+  list.pushUnique(&a);
+  list.pushUnique(&b);
+  list.pushUnique(&a);
+  list.pushUnique(&c);
+  CHECK(list.size() == 3);
+  CHECK(contents(list) == std::vector<LayoutStyleApplier*>{&a, &b, &c});
+
+  // Past the inline slots the list moves to the heap, keeping its order and
+  // still skipping repeats.
+  list.pushUnique(&d);
+  list.pushUnique(&b);
+  list.pushUnique(&e);
+  list.pushUnique(&d);
+  CHECK(list.size() == 5);
+  CHECK(contents(list) == std::vector<LayoutStyleApplier*>{&a, &b, &c, &d, &e});
+}
+#endif
diff --git a/tests/unit_tests/runtime/layout_test.cpp b/tests/unit_tests/runtime/layout_test.cpp
index 26d04f2..91ecbcd 100644
--- a/tests/unit_tests/runtime/layout_test.cpp
+++ b/tests/unit_tests/runtime/layout_test.cpp
@@ -6,10 +6,13 @@
 #include "rive/text/text.hpp"
 #include "rive/viewmodel/viewmodel_instance_boolean.hpp"
 #include "utils/no_op_factory.hpp"
+#include "yoga/YGNode.h"
+#include "yoga/YGStyle.h"
 #include "rive_file_reader.hpp"
 #include "rive_testing.hpp"
 #include "utils/serializing_factory.hpp"
 #include <catch.hpp>
+#include <algorithm>
 #include <cstdio>
 
 TEST_CASE("LayoutComponent FlexDirection row", "[layout]")
@@ -508,6 +511,117 @@
   REQUIRE(artboard->layoutHeight() == 512.0f);
 }
 
+// The style names its layout as its parent, so it joins the layout's children
+// on its own; the layout must not add it a second time.
+static void checkStyleIsChildOnce(rive::Artboard* artboard)
+{
+  int layouts = 0;
+  for (auto* object : artboard->objects())
+  {
+    if (object == nullptr || !object->is<rive::LayoutComponent>())
+    {
+      continue;
+    }
+    auto* layout = object->as<rive::LayoutComponent>();
+    REQUIRE(layout->style() != nullptr);
+    auto& children = layout->children();
+    CHECK(std::count(children.begin(), children.end(), layout->style()) == 1);
+    layouts++;
+  }
+  // The artboard and its three layouts.
+  REQUIRE(layouts == 4);
+}
+
+TEST_CASE("A layout's style is one of its children once", "[layout]")
+{
+  auto file = ReadRiveFile("assets/layout/layout_horizontal.riv");
+  checkStyleIsChildOnce(file->artboard());
+  auto instance = file->artboardDefault();
+  checkStyleIsChildOnce(instance.get());
+}
+
+// Yoga allocates a node's grid properties on their first write. While none
+// are allocated, the getters hand out one shared empty list.
+static bool hasGridStyle(const YGStyle& style)
+{
+  static const YGStyle unallocated;
+  return &style.gridTemplateColumns() != &unallocated.gridTemplateColumns();
+}
+
+TEST_CASE("Flex layouts leave Yoga's grid properties unallocated", "[layout]")
+{
+  auto file = ReadRiveFile("assets/layout/layout_horizontal.riv");
+  auto artboard = file->artboardDefault();
+  artboard->advance(0.0f);
+  int flexLayouts = 0;
+  for (auto* object : artboard->objects())
+  {
+    if (object == nullptr || !object->is<rive::LayoutComponent>())
+    {
+      continue;
+    }
+    auto* layout = object->as<rive::LayoutComponent>();
+    if (layout->style()->display() != YGDisplayFlex)
+    {
+      continue;
+    }
+    auto* node = static_cast<YGNode*>(layout->layoutNode(0));
+    REQUIRE(node != nullptr);
+    CHECK(!hasGridStyle(node->getStyle()));
+    flexLayouts++;
+  }
+  REQUIRE(flexLayouts == 4);
+}
+
+TEST_CASE("Syncing a layout's unchanged children keeps Yoga's list", "[layout]")
+{
+  auto file = ReadRiveFile("assets/layout/layout_horizontal.riv");
+  auto artboard = file->artboardDefault();
+  artboard->advance(0.0f);
+  auto target2 = artboard->find<rive::LayoutComponent>("LayoutComponent2");
+  auto target3 = artboard->find<rive::LayoutComponent>("LayoutComponent3");
+  REQUIRE(target2 != nullptr);
+  REQUIRE(target3 != nullptr);
+  REQUIRE(target2->worldTransform().decompose().x() == 100);
+  REQUIRE(target3->worldTransform().decompose().x() == 200);
+
+  auto rebuilds = rive::LayoutComponent::sm_layoutChildRebuilds;
+  artboard->syncLayoutChildren();
+  artboard->syncLayoutChildren();
+  CHECK(rive::LayoutComponent::sm_layoutChildRebuilds == rebuilds);
+  artboard->advance(0.0f);
+  CHECK(target2->worldTransform().decompose().x() == 100);
+  CHECK(target3->worldTransform().decompose().x() == 200);
+}
+
+TEST_CASE("A layout marked dirty twice is listed once", "[layout]")
+{
+  auto file = ReadRiveFile("assets/layout/layout_horizontal.riv");
+  auto artboard = file->artboardDefault();
+  artboard->advance(0.0f);
+  REQUIRE(!artboard->hasDirtyLayout());
+  auto layout = artboard->find<rive::LayoutComponent>("LayoutComponent1");
+  REQUIRE(layout != nullptr);
+
+  artboard->markLayoutDirty(layout);
+  artboard->markLayoutDirty(layout);
+  REQUIRE(artboard->hasDirtyLayout());
+  // Listed once, so cleaning it once empties the list.
+  artboard->cleanLayout(layout);
+  CHECK(!artboard->hasDirtyLayout());
+
+  // Cleaning cleared its mark, so it's listed again, and syncing empties the
+  // list for good.
+  artboard->markLayoutDirty(layout);
+  CHECK(artboard->hasDirtyLayout());
+  artboard->advance(0.0f);
+  CHECK(!artboard->hasDirtyLayout());
+  artboard->markLayoutDirty(layout);
+  CHECK(artboard->hasDirtyLayout());
+  artboard->advance(0.0f);
+  CHECK(!artboard->hasDirtyLayout());
+}
+
 TEST_CASE("Multiple layout collapsing and soloing in hierarchy.", "[silver]")
 {
   rive::SerializingFactory silver;
diff --git a/tests/unit_tests/runtime/rounded_rect_path_test.cpp b/tests/unit_tests/runtime/rounded_rect_path_test.cpp
index cfbafcf..5305b40 100644
--- a/tests/unit_tests/runtime/rounded_rect_path_test.cpp
+++ b/tests/unit_tests/runtime/rounded_rect_path_test.cpp
@@ -192,3 +192,23 @@
     requireSamePath(*oldWay.rawPath(), *newWay.rawPath(), c.label);
   }
 }
+
+TEST_CASE("rounded rect sizes its path once", "[rawpath]")
+{
+  // No corners rounded, and three: a move, four lines and a close, and a
+  // cubic and its three points per rounded corner. Growing an entry at a time
+  // would leave the capacities at powers of two instead.
+  RawPath square;
+  Path::addRoundedRect(square, AABB(0.0f, 0.0f, 100.0f, 50.0f), 0, 0, 0, 0);
+  CHECK(square.verbs().size() == 6);
+  CHECK(square.points().size() == 5);
+  CHECK(square.verbCapacity() == 6);
+  CHECK(square.pointCapacity() == 5);
+
+  RawPath rounded;
+  Path::addRoundedRect(rounded, AABB(0.0f, 0.0f, 100.0f, 50.0f), 8, 8, 0, 8);
+  CHECK(rounded.verbs().size() == 9);
+  CHECK(rounded.points().size() == 14);
+  CHECK(rounded.verbCapacity() == 9);
+  CHECK(rounded.pointCapacity() == 14);
+}
diff --git a/tests/unit_tests/runtime/state_machine_test.cpp b/tests/unit_tests/runtime/state_machine_test.cpp
index 26158b2..26bfdeb 100644
--- a/tests/unit_tests/runtime/state_machine_test.cpp
+++ b/tests/unit_tests/runtime/state_machine_test.cpp
@@ -299,13 +299,16 @@
   stateMachineInstance->advanceAndApply(0.1f);
   abi->advance(0.1f);
 
-  auto rect1 = abi->children()[9]->as<rive::Shape>();
+  auto rect1 = abi->find<rive::Shape>("rect1");
+  REQUIRE(rect1 != nullptr);
   REQUIRE(rect1->name() == "rect1");
 
-  auto rect2 = abi->children()[7]->as<rive::Shape>();
+  auto rect2 = abi->find<rive::Shape>("rect2");
+  REQUIRE(rect2 != nullptr);
   REQUIRE(rect2->name() == "rect2");
 
-  auto triangle = abi->children()[5]->as<rive::Shape>();
+  auto triangle = abi->find<rive::Shape>("triangle");
+  REQUIRE(triangle != nullptr);
   REQUIRE(triangle->name() == "triangle");
 
   // This blend rotates 2 * Pi. At 50% it should have rotated 1 * Pi
@@ -388,11 +391,13 @@
   stateMachineInstance->advanceAndApply(0.1f);
   abi->advance(0.1f);
 
-  auto rect = abi->children()[7]->as<rive::Shape>();
+  auto rect = abi->find<rive::Shape>("rectangle");
+  REQUIRE(rect != nullptr);
   REQUIRE(rect->name() == "rectangle");
   REQUIRE(rect->x() == 50);
 
-  auto ellipse = abi->children()[5]->as<rive::Shape>();
+  auto ellipse = abi->find<rive::Shape>("ellipse");
+  REQUIRE(ellipse != nullptr);
   REQUIRE(ellipse->name() == "ellipse");
   REQUIRE(ellipse->x() == Approx(440.31241));