fix(scripting): mint 2d canvases before the device binds, like gpu canvases (#15399)

* fix(scripting): mint 2d canvases before the device binds, like gpu canvases

Since #15312 a gpu canvas exists at init on web, so scripts run their GPU
setup there. A sized 2D canvas made at init still waited for the device and
had no image, so `canvas.image.view()` came back null and scripts that need
it trapped.

Both lanes now mint 2D canvases through the same helper as gpu canvases. A
recorded Luau canvas no longer needs the render context to begin a frame.

* test(scripting): cover a 2d canvas resized before the device binds

The Luau resize path had no test once context:canvas() started minting at
creation. Also fixes two comments that still said a recording host waits for
its device, and drops one that sat on the branch it didn't describe.

* refactor(scripting): share the canvas mint path and test its replay backing

---------

Co-authored-by: Luigi Rosso <luigi.rosso@gmail.com>
Rive-Mono-Commit: a71f1fe15ad5e5e51ec128963e3bd4273f42d9c3
diff --git a/include/rive/lua/rive_lua_libs.hpp b/include/rive/lua/rive_lua_libs.hpp
index 85a5210..c0390f8 100644
--- a/include/rive/lua/rive_lua_libs.hpp
+++ b/include/rive/lua/rive_lua_libs.hpp
@@ -988,10 +988,9 @@
   lua_State* m_L = nullptr;
   int m_imageRef = LUA_NOREF;
   gpu::RenderContext* renderCtx = nullptr; // needed for resize()
-  // Size a resize() asked for while no device existed. Web attaches one per
-  // render texture after layout has already run, and a generator resizes
+  // Size asked for while no session or device could mint it. A generator sizes
   // once, so the request is held here and honoured on the first access after
-  // a device appears. Zero once satisfied.
+  // one can. Zero once satisfied.
   uint32_t pendingWidth = 0;
   uint32_t pendingHeight = 0;
 };
@@ -2278,12 +2277,16 @@
 #ifdef RIVE_CANVAS
 // Allocates a script canvas backing, deferring when a session is recording
 // or the device was late bound, since either way the replay worker owns the
-// texture.
+// texture. Null when there is neither a session nor a device.
 rcp<gpu::RenderCanvas> allocScriptRenderCanvas(
     gpu::RenderContext* rc,
     ScriptingContext* ctx,
     uint32_t width,
     uint32_t height);
+void canvas_satisfyPending(lua_State* L, ScriptedCanvas* self);
+#ifdef RIVE_ORE
+void gpucanvas_satisfyPending(lua_State* L, ScriptedGPUCanvas* self);
+#endif
 #endif
 
 class ScopedScriptedObjectContext
diff --git a/src/lua/lua_scripted_context.cpp b/src/lua/lua_scripted_context.cpp
index 9d3d789..8ac0e00 100644
--- a/src/lua/lua_scripted_context.cpp
+++ b/src/lua/lua_scripted_context.cpp
@@ -505,48 +505,19 @@
         {
           return 1;
         }
-        if (renderCtx == nullptr)
+        // A recording session mints the canvas with no device bound.
+        if (renderCtx == nullptr &&
+            scriptingCtx->deferredCanvasHost() == nullptr)
         {
-          // A recording session binds its device after import, and
-          // generators size their canvas at construction, before any
-          // texture exists. Record the request; satisfyPending
-          // materializes it on first use once the device arrives.
-          if (scriptingCtx->deferredCanvasHost() != nullptr)
-          {
-            handle->pendingWidth = cw;
-            handle->pendingHeight = ch;
-            return 1;
-          }
           luaL_error(
               L,
               "context:canvas() requires a RenderContext — call "
               "setRenderContext() first");
           return 0;
         }
-
-        auto canvas = allocScriptRenderCanvas(renderCtx, scriptingCtx, cw, ch);
-        if (!canvas)
-        {
-          luaL_error(L, "context:canvas() failed to create RenderCanvas");
-          return 0;
-        }
-        handle->canvas = std::move(canvas);
-        // Create a ScriptedImage backed by canvas->renderImage() so
-        // the script can composite it with renderer:drawImage()
-        auto* img = lua_newrive<ScriptedImage>(L);
-        img->image = ref_rcp(
-            static_cast<RenderImage*>(handle->canvas->renderImage()));
-        // Provenance: canvas images carry no distinguishing rtti, so
-        // this is the only reliable signal that Image:view() has a
-        // canvas rather than a decoded asset. satisfyPending sets it
-        // on the late bound path; set it here too or the two paths
-        // disagree. The field only exists with ore, matching where
-        // the recording dispatch that reads it lives.
-#if defined(RIVE_CANVAS) && defined(RIVE_ORE)
-        img->sourceCanvas = handle->canvas;
-#endif
-        handle->m_imageRef = lua_ref(L, -1);
-        lua_pop(L, 1); // pop image, handle remains on top
+        handle->pendingWidth = cw;
+        handle->pendingHeight = ch;
+        canvas_satisfyPending(L, handle);
         return 1;
 #endif
       }
@@ -617,9 +588,7 @@
               "setRenderContext() first");
           return 0;
         }
-        auto* oreCtx = static_cast<ore::Context*>(
-            gpuScriptingCtx->oreContext());
-        if (oreCtx == nullptr)
+        if (gpuScriptingCtx->oreContext() == nullptr)
         {
           luaL_error(
               L,
@@ -627,40 +596,9 @@
               "scriptingWorkspaceSetOreContext() before requestVM()");
           return 0;
         }
-
-        auto canvas = allocScriptRenderCanvas(
-            gpuRenderCtx,
-            gpuScriptingCtx,
-            gw,
-            gh);
-        if (!canvas)
-        {
-          // A host that cannot mint before its device binds holds the size
-          // until one does.
-          if (gpuRenderCtx == nullptr)
-          {
-            handle->pendingWidth = gw;
-            handle->pendingHeight = gh;
-            return 1;
-          }
-          luaL_error(L, "context:gpuCanvas() failed to create RenderCanvas");
-          return 0;
-        }
-        auto colorView = oreCtx->wrapCanvasTexture(canvas.get());
-        if (!colorView)
-        {
-          luaL_error(L, "context:gpuCanvas() failed to wrap canvas texture");
-          return 0;
-        }
-        handle->canvas = std::move(canvas);
-        handle->oreColorView = std::move(colorView);
-
-        auto* img = lua_newrive<ScriptedImage>(L);
-        img->image = ref_rcp(
-            static_cast<RenderImage*>(handle->canvas->renderImage()));
-        img->sourceCanvas = handle->canvas;
-        handle->m_imageRef = lua_ref(L, -1);
-        lua_pop(L, 1); // pop image, handle remains on top
+        handle->pendingWidth = gw;
+        handle->pendingHeight = gh;
+        gpucanvas_satisfyPending(L, handle);
         return 1;
 #endif
       }
diff --git a/src/lua/renderer/lua_gpu.cpp b/src/lua/renderer/lua_gpu.cpp
index e29941d..7ee4ade 100644
--- a/src/lua/renderer/lua_gpu.cpp
+++ b/src/lua/renderer/lua_gpu.cpp
@@ -2993,7 +2993,10 @@
   {
     return deferredHost->makeUnboundContentCanvas(width, height);
   }
-  assert(rc != nullptr);
+  if (rc == nullptr)
+  {
+    return nullptr;
+  }
   if (ctx->renderContextIsLateBound())
   {
     return rc->makeDeferredRenderCanvas(width, height);
@@ -3013,11 +3016,11 @@
   return static_cast<gpu::RenderContext*>(scriptingCtx->renderContext());
 }
 
-// Allocates the backing for a pending size, if there is one and a device has
-// turned up to allocate it against. Errors only on a device that is present and
-// refuses; a device that has not arrived yet leaves the request pending, which
-// is what makes a size-less canvas usable on a host that attaches late.
-static void gpucanvas_satisfyPending(lua_State* L, ScriptedGPUCanvas* self)
+// Allocates the backing for a pending size, if there is one and a session or
+// device can mint it. Errors only on a device that is present and refuses;
+// otherwise the request stays pending, which is what makes a size-less canvas
+// usable on a host that attaches late.
+void rive::gpucanvas_satisfyPending(lua_State* L, ScriptedGPUCanvas* self)
 {
   if (self->pendingWidth == 0 || self->pendingHeight == 0)
   {
@@ -3025,16 +3028,11 @@
   }
   auto* scriptingCtx = static_cast<ScriptingContext*>(lua_getthreaddata(L));
   auto* renderCtx = liveRenderContext(scriptingCtx);
-  if (renderCtx == nullptr && scriptingCtx->deferredCanvasHost() == nullptr)
-  {
-    return;
-  }
   auto* oreCtx = getOreContext(L);
   if (oreCtx == nullptr)
   {
     return;
   }
-  self->renderCtx = renderCtx;
   uint32_t w = self->pendingWidth, h = self->pendingHeight;
 
   // Allocate and wrap the new backing BEFORE touching the existing
@@ -3048,12 +3046,12 @@
     {
       return;
     }
-    luaL_error(L, "GPUCanvas:resize() failed to create RenderCanvas");
+    luaL_error(L, "GPUCanvas failed to create RenderCanvas");
   }
   auto newColorView = oreCtx->wrapCanvasTexture(newCanvas.get());
   if (!newColorView)
   {
-    luaL_error(L, "GPUCanvas:resize() failed to wrap canvas texture");
+    luaL_error(L, "GPUCanvas failed to wrap canvas texture");
   }
 
   if (self->m_L != nullptr && self->m_imageRef != LUA_NOREF)
@@ -3063,6 +3061,7 @@
   }
   self->canvas = std::move(newCanvas);
   self->oreColorView = std::move(newColorView);
+  self->renderCtx = renderCtx;
   self->pendingWidth = 0;
   self->pendingHeight = 0;
 
@@ -3252,9 +3251,8 @@
 // ============================================================================
 
 // The 2D counterpart of gpucanvas_satisfyPending, for the same reason: a
-// size-less canvas is legal, and on web the device shows up after layout has
-// already handed the generator its real size.
-static void canvas_satisfyPending(lua_State* L, ScriptedCanvas* self)
+// size-less canvas is legal, and a host that cannot mint yet holds the size.
+void rive::canvas_satisfyPending(lua_State* L, ScriptedCanvas* self)
 {
   if (self->pendingWidth == 0 || self->pendingHeight == 0)
   {
@@ -3262,11 +3260,6 @@
   }
   auto* scriptingCtx = static_cast<ScriptingContext*>(lua_getthreaddata(L));
   auto* renderCtx = liveRenderContext(scriptingCtx);
-  if (renderCtx == nullptr)
-  {
-    return;
-  }
-  self->renderCtx = renderCtx;
 
   // Allocate the new backing BEFORE touching the existing canvas/imageRef.
   // If allocation throws (via luaL_error), the canvas keeps its previous,
@@ -3278,7 +3271,12 @@
       self->pendingHeight);
   if (!newCanvas)
   {
-    luaL_error(L, "Canvas:resize() failed to create RenderCanvas");
+    // A host that cannot mint before its device binds keeps the size.
+    if (renderCtx == nullptr)
+    {
+      return;
+    }
+    luaL_error(L, "Canvas failed to create RenderCanvas");
   }
 
   if (self->m_L != nullptr && self->m_imageRef != LUA_NOREF)
@@ -3287,6 +3285,7 @@
     self->m_imageRef = LUA_NOREF;
   }
   self->canvas = std::move(newCanvas);
+  self->renderCtx = renderCtx;
   self->pendingWidth = 0;
   self->pendingHeight = 0;
 
@@ -3347,10 +3346,6 @@
 {
   auto* self = lua_torive<ScriptedCanvas>(L, 1);
   canvas_satisfyPending(L, self);
-  if (self->renderCtx == nullptr)
-  {
-    luaL_error(L, "Canvas: renderCtx not initialized");
-  }
   auto* scriptingContext = static_cast<ScriptingContext*>(lua_getthreaddata(L));
   // Recording brackets the content instead of opening a real frame; an
   // immediate context cannot nest one inside the open screen frame.
@@ -3399,6 +3394,10 @@
   }
   else
   {
+    if (self->renderCtx == nullptr)
+    {
+      luaL_error(L, "Canvas: renderCtx not initialized");
+    }
     self->renderCtx->beginFrame(desc);
     // Allocate a RiveRenderer that issues into this render context. Deleted
     // in endFrame() (or in the destructor if endFrame is never called).
diff --git a/src/wasm/wasm_scripting_vm.cpp b/src/wasm/wasm_scripting_vm.cpp
index 6a2fca4..700a5a2 100644
--- a/src/wasm/wasm_scripting_vm.cpp
+++ b/src/wasm/wasm_scripting_vm.cpp
@@ -3282,6 +3282,26 @@
   }
 }
 
+#ifdef RIVE_CANVAS
+// A deferred host mints a canvas before any device binds; only immediate
+// needs a render context.
+rcp<gpu::RenderCanvas> makeScriptCanvas(
+    WasmScriptingVM* vm,
+    uint32_t width,
+    uint32_t height)
+{
+  if (auto* deferredHost = vm->factory()->deferredCanvasHost())
+  {
+    return deferredHost->makeUnboundContentCanvas(width, height);
+  }
+  auto* renderContext = static_cast<gpu::RenderContext*>(
+      vm->factory()->renderContext());
+  return renderContext != nullptr
+             ? renderContext->makeRenderCanvas(width, height)
+             : nullptr;
+}
+#endif
+
 #if defined(RIVE_CANVAS) && defined(RIVE_ORE)
 struct HostGpuCanvas
 {
@@ -3383,24 +3403,6 @@
   return passed;
 }
 
-// A deferred host mints a canvas before any device binds; only immediate
-// needs a render context.
-rcp<gpu::RenderCanvas> makeGpuCanvas(
-    WasmScriptingVM* vm,
-    uint32_t width,
-    uint32_t height)
-{
-  if (auto* deferredHost = vm->factory()->deferredCanvasHost())
-  {
-    return deferredHost->makeUnboundContentCanvas(width, height);
-  }
-  auto* renderContext = static_cast<gpu::RenderContext*>(
-      vm->factory()->renderContext());
-  return renderContext != nullptr
-             ? renderContext->makeRenderCanvas(width, height)
-             : nullptr;
-}
-
 uint32_t gpuCanvasNewImpl(WasmScriptingVM* vm, uint32_t width, uint32_t height)
 {
   if (vm == nullptr || vm->factory() == nullptr)
@@ -3420,7 +3422,7 @@
   {
     return 0;
   }
-  auto canvas = makeGpuCanvas(vm, width, height);
+  auto canvas = makeScriptCanvas(vm, width, height);
   if (canvas == nullptr)
   {
     return 0;
@@ -3515,7 +3517,7 @@
   {
     return 0;
   }
-  auto canvas = makeGpuCanvas(vm, width, height);
+  auto canvas = makeScriptCanvas(vm, width, height);
   if (canvas == nullptr)
   {
     return 0;
@@ -5599,7 +5601,7 @@
 struct HostCanvas
 {
   rcp<gpu::RenderCanvas> canvas;
-  // A size requested before the device bound, allocated on first use.
+  // A size no host could mint yet, allocated on first use.
   uint32_t pendingWidth = 0;
   uint32_t pendingHeight = 0;
   cmd::DeferredCanvasHost* frameHost = nullptr;
@@ -5617,29 +5619,23 @@
       vm->handles().resolve(handle, WasmScriptingVM::HandleTable::Tag::canvas));
 }
 
-// Allocates a pending size once a device is there to allocate against.
-// False only when a device is present and refuses.
+// Allocates a pending size once a host can mint it. False only when a device
+// is present and refuses.
 bool canvasSatisfyPending(WasmScriptingVM* vm, HostCanvas* host)
 {
   if (host->pendingWidth == 0 || host->pendingHeight == 0)
   {
     return true;
   }
-  auto* renderContext = static_cast<gpu::RenderContext*>(
-      vm->factory()->renderContext());
-  if (renderContext == nullptr)
+  rcp<gpu::RenderCanvas> canvas = makeScriptCanvas(
+      vm,
+      host->pendingWidth,
+      host->pendingHeight);
+  if (canvas == nullptr && vm->factory()->renderContext() == nullptr)
   {
     return true;
   }
   // A refused size leaves the previous backing in place.
-  auto* deferredHost = vm->factory()->deferredCanvasHost();
-  rcp<gpu::RenderCanvas> canvas = deferredHost != nullptr
-                                      ? deferredHost->makeContentCanvas(
-                                            host->pendingWidth,
-                                            host->pendingHeight)
-                                      : renderContext->makeRenderCanvas(
-                                            host->pendingWidth,
-                                            host->pendingHeight);
   host->pendingWidth = 0;
   host->pendingHeight = 0;
   if (canvas == nullptr)
@@ -5661,7 +5657,7 @@
   {
     host->pendingWidth = width;
     host->pendingHeight = height;
-    // A size only waits when a recording host will bind a device later.
+    // A size waits only on a recording host that can't mint it yet.
     if (!canvasSatisfyPending(vm, host) ||
         (host->canvas == nullptr &&
          vm->factory()->deferredCanvasHost() == nullptr))
diff --git a/tests/unit_tests/runtime/scripting/scripting_deferred_canvas_test.cpp b/tests/unit_tests/runtime/scripting/scripting_deferred_canvas_test.cpp
new file mode 100644
index 0000000..1184524
--- /dev/null
+++ b/tests/unit_tests/runtime/scripting/scripting_deferred_canvas_test.cpp
@@ -0,0 +1,205 @@
+// Canvases a script makes before its recording session has a device. Web binds
+// the replay worker's device at the first frame, after scripts init, so the
+// canvas has to be minted from the session alone.
+
+#include "catch.hpp"
+#include "scripting_test_utilities.hpp"
+#include "rive/lua/rive_lua_libs.hpp"
+#include "utils/no_op_factory.hpp"
+
+#if defined(RIVE_CANVAS) && defined(RIVE_ORE)
+#include "common/render_context_null.hpp"
+#include "rive/renderer/cmd/deferred_replayer.hpp"
+#include "rive/renderer/cmd/deferred_session.hpp"
+#include "rive/renderer/render_canvas.hpp"
+
+using namespace rive;
+
+namespace
+{
+// Leaves init's `results` results on the stack.
+void callInit(ScriptingTest& vm, int results)
+{
+  ScriptedObjectTest scriptedObjectTest;
+  lua_State* L = vm.state();
+  lua_getglobal(L, "init");
+  lua_pushvalue(L, -2);
+  lua_newrive<ScriptedContext>(L, &scriptedObjectTest);
+  if (lua_pcall(L, 2, results, 0) != LUA_OK)
+  {
+    FAIL(lua_tostring(L, -1));
+  }
+}
+
+bool runInit(ScriptingTest& vm)
+{
+  callInit(vm, 1);
+  return lua_toboolean(vm.state(), -1);
+}
+
+// Backs canvases on a GPU free context and records whose content it opened.
+class BackingSink : public cmd::DeferredFrameSink
+{
+public:
+  std::vector<gpu::RenderCanvas*> contentOpened;
+
+  Factory* factory() override { return m_rc.get(); }
+  ore::Context* oreContext() override { return nullptr; }
+  gpu::RenderContext* renderContext() override { return m_rc.get(); }
+  Renderer* beginScreenFrame(uint64_t) override { return nullptr; }
+  Renderer* beginCanvasContent(gpu::RenderCanvas* canvas, uint32_t) override
+  {
+    contentOpened.push_back(canvas);
+    return nullptr;
+  }
+
+private:
+  std::unique_ptr<gpu::RenderContext> m_rc = RenderContextNULL::MakeContext();
+};
+} // namespace
+
+TEST_CASE(
+    "a 2d canvas made before the device binds is backed at replay",
+    "[scripting][deferred]")
+{
+  cmd::DeferredSession session(ore::ReplayCaps{});
+  ScriptingTest vm(
+      R"(
+function init(self, context)
+  local canvas = context:canvas({ width = 8, height = 8 })
+  local resized = context:canvas()
+  resized:resize(16, 4)
+  assert(canvas.width == 8 and resized.width == 16, 'size')
+  assert(canvas.image:view() ~= nil and resized.image:view() ~= nil, 'view')
+  canvas:beginFrame()
+  canvas:endFrame()
+  resized:beginFrame()
+  resized:endFrame()
+  return canvas, resized
+end
+)",
+      1,
+      false,
+      {},
+      true,
+      &session);
+  callInit(vm, 2);
+  lua_State* L = vm.state();
+  auto* madeHandle = lua_torive<ScriptedCanvas>(L, -2);
+  rcp<gpu::RenderCanvas> made = madeHandle->canvas;
+  rcp<gpu::RenderCanvas> resized = lua_torive<ScriptedCanvas>(L, -1)->canvas;
+  REQUIRE(made != nullptr);
+  REQUIRE(resized != nullptr);
+  CHECK(!made->isBacked());
+  CHECK(!resized->isBacked());
+  lua_getref(L, madeHandle->m_imageRef);
+  CHECK(lua_torive<ScriptedImage>(L, -1)->sourceCanvas == made);
+  lua_pop(L, 1);
+
+  BackingSink sink;
+  cmd::DeferredReplayer replayer;
+  replayer.replayFrame(cmd::snapshotFrame(session), sink);
+
+  CHECK(made->isBacked());
+  CHECK(resized->isBacked());
+  CHECK(resized->width() == 16);
+  CHECK(
+      sink.contentOpened ==
+      std::vector<gpu::RenderCanvas*>{made.get(), resized.get()});
+}
+
+TEST_CASE(
+    "an immediate 2d canvas still needs a render context",
+    "[scripting][deferred]")
+{
+  NoOpFactory factory;
+  ScriptingTest vm(
+      R"(
+function init(self, context)
+  local ok, err = pcall(function()
+    context:canvas({ width = 4, height = 4 })
+  end)
+  return not ok and string.find(err, 'RenderContext') ~= nil
+end
+)",
+      1,
+      false,
+      {},
+      true,
+      &factory);
+  CHECK(runInit(vm));
+}
+
+TEST_CASE(
+    "a gpu canvas made before the device binds has its backing and view",
+    "[scripting][deferred]")
+{
+  cmd::DeferredSession session(ore::ReplayCaps{});
+  REQUIRE(session.renderContext() == nullptr);
+  ScriptingTest vm(
+      R"(
+function init(self, context)
+  local canvas = context:gpuCanvas({ width = 64, height = 32 })
+  assert(canvas.width == 64 and canvas.height == 32, 'size')
+  assert(canvas.image ~= nil, 'image')
+  assert(canvas:colorView().format == 'rgba8unorm', 'view')
+  return true
+end
+)",
+      1,
+      false,
+      {},
+      true,
+      &session);
+  CHECK(runInit(vm));
+}
+
+TEST_CASE(
+    "a gpu canvas resized before the device binds takes the new size",
+    "[scripting][deferred]")
+{
+  cmd::DeferredSession session(ore::ReplayCaps{});
+  ScriptingTest vm(
+      R"(
+function init(self, context)
+  local canvas = context:gpuCanvas()
+  canvas:resize(128, 16)
+  assert(canvas.width == 128 and canvas.height == 16, 'size')
+  local first = canvas.image
+  assert(first ~= nil and canvas:colorView() ~= nil, 'backing')
+  canvas:resize(8, 8)
+  assert(canvas.width == 8 and canvas.height == 8, 'resized')
+  assert(canvas.image ~= first, 'new backing')
+  return true
+end
+)",
+      1,
+      false,
+      {},
+      true,
+      &session);
+  CHECK(runInit(vm));
+}
+
+TEST_CASE(
+    "an immediate gpu canvas still needs a render context",
+    "[scripting][deferred]")
+{
+  NoOpFactory factory;
+  ScriptingTest vm(
+      R"(
+function init(self, context)
+  local ok, err = pcall(function()
+    context:gpuCanvas({ width = 4, height = 4 })
+  end)
+  return not ok and string.find(err, 'RenderContext') ~= nil
+end
+)",
+      1,
+      false,
+      {},
+      true,
+      &factory);
+  CHECK(runInit(vm));
+}
+#endif
diff --git a/tests/unit_tests/runtime/scripting/scripting_deferred_gpu_canvas_test.cpp b/tests/unit_tests/runtime/scripting/scripting_deferred_gpu_canvas_test.cpp
deleted file mode 100644
index 25e1c05..0000000
--- a/tests/unit_tests/runtime/scripting/scripting_deferred_gpu_canvas_test.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-// A GPU canvas a script makes before its recording session has a device. Web
-// binds the replay worker's device at the first frame, after scripts init, so
-// the canvas has to be minted from the session alone.
-
-#include "catch.hpp"
-#include "scripting_test_utilities.hpp"
-#include "rive/lua/rive_lua_libs.hpp"
-#include "utils/no_op_factory.hpp"
-
-#if defined(RIVE_CANVAS) && defined(RIVE_ORE)
-#include "rive/renderer/cmd/deferred_session.hpp"
-
-using namespace rive;
-
-namespace
-{
-bool runInit(ScriptingTest& vm)
-{
-  ScriptedObjectTest scriptedObjectTest;
-  lua_State* L = vm.state();
-  lua_getglobal(L, "init");
-  lua_pushvalue(L, -2);
-  lua_newrive<ScriptedContext>(L, &scriptedObjectTest);
-  if (lua_pcall(L, 2, 1, 0) != LUA_OK)
-  {
-    FAIL(lua_tostring(L, -1));
-  }
-  return lua_toboolean(L, -1);
-}
-} // namespace
-
-TEST_CASE(
-    "a gpu canvas made before the device binds has its backing and view",
-    "[scripting][deferred]")
-{
-  cmd::DeferredSession session(ore::ReplayCaps{});
-  REQUIRE(session.renderContext() == nullptr);
-  ScriptingTest vm(
-      R"(
-function init(self, context)
-  local canvas = context:gpuCanvas({ width = 64, height = 32 })
-  assert(canvas.width == 64 and canvas.height == 32, 'size')
-  assert(canvas.image ~= nil, 'image')
-  assert(canvas:colorView().format == 'rgba8unorm', 'view')
-  return true
-end
-)",
-      1,
-      false,
-      {},
-      true,
-      &session);
-  CHECK(runInit(vm));
-}
-
-TEST_CASE(
-    "a gpu canvas resized before the device binds takes the new size",
-    "[scripting][deferred]")
-{
-  cmd::DeferredSession session(ore::ReplayCaps{});
-  ScriptingTest vm(
-      R"(
-function init(self, context)
-  local canvas = context:gpuCanvas()
-  canvas:resize(128, 16)
-  assert(canvas.width == 128 and canvas.height == 16, 'size')
-  local first = canvas.image
-  assert(first ~= nil and canvas:colorView() ~= nil, 'backing')
-  canvas:resize(8, 8)
-  assert(canvas.width == 8 and canvas.height == 8, 'resized')
-  assert(canvas.image ~= first, 'new backing')
-  return true
-end
-)",
-      1,
-      false,
-      {},
-      true,
-      &session);
-  CHECK(runInit(vm));
-}
-
-TEST_CASE(
-    "an immediate gpu canvas still needs a render context",
-    "[scripting][deferred]")
-{
-  NoOpFactory factory;
-  ScriptingTest vm(
-      R"(
-function init(self, context)
-  local ok, err = pcall(function()
-    context:gpuCanvas({ width = 4, height = 4 })
-  end)
-  return not ok and string.find(err, 'RenderContext') ~= nil
-end
-)",
-      1,
-      false,
-      {},
-      true,
-      &factory);
-  CHECK(runInit(vm));
-}
-#endif
diff --git a/tests/unit_tests/runtime/scripting/scripting_routing_test.cpp b/tests/unit_tests/runtime/scripting/scripting_routing_test.cpp
index cc8d985..22bb51d 100644
--- a/tests/unit_tests/runtime/scripting/scripting_routing_test.cpp
+++ b/tests/unit_tests/runtime/scripting/scripting_routing_test.cpp
@@ -169,7 +169,7 @@
 
 #if defined(RIVE_CANVAS) && defined(RIVE_ORE)
 TEST_CASE(
-    "sized canvas construction goes pending until a device binds",
+    "a sized canvas waits on a host that cannot mint it yet",
     "[scripting]")
 {
   // The factory answers deferredCanvasHost(), the same derivation a session
@@ -201,7 +201,7 @@
 // The reachable symptom of the mismatch: without routing the script is
 // refused outright rather than recording for the device that binds later.
 TEST_CASE(
-    "a caller supplied VM's sized canvas goes pending, not refused",
+    "a caller supplied VM's sized canvas reaches its host, not refused",
     "[scripting]")
 {
   NoOpFactory constructionFactory;