fix(apple): retain and clear artboard/image property values in ViewModelInstance (#12561) d938779f2b

Co-authored-by: David Skuza <david@rive.app>
diff --git a/.rive_head b/.rive_head
index 70e9957..45bc7cc 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-1cac2869056d607aa43ab2cb133e24161886fc50
+d938779f2bb5ff346120f5894dddefaef3d547ae
diff --git a/src/command_server.cpp b/src/command_server.cpp
index 96eb829..71f585c 100644
--- a/src/command_server.cpp
+++ b/src/command_server.cpp
@@ -2238,7 +2238,7 @@
                 ViewModelInstanceHandle handle = RIVE_NULL_HANDLE;
                 ViewModelInstanceHandle nestedHandle = RIVE_NULL_HANDLE;
                 RenderImageHandle imageHandle = RIVE_NULL_HANDLE;
-                ArtboardHandle artboadHandle = RIVE_NULL_HANDLE;
+                ArtboardHandle artboardHandle = RIVE_NULL_HANDLE;
                 uint64_t requestId;
                 CommandQueue::ViewModelInstanceData value;
 
@@ -2272,7 +2272,7 @@
                         commandStream >> imageHandle;
                         break;
                     case DataType::artboard:
-                        commandStream >> artboadHandle;
+                        commandStream >> artboardHandle;
                         break;
                     default:
                         RIVE_UNREACHABLE();
@@ -2482,11 +2482,15 @@
                         }
                         case DataType::assetImage:
                         {
-                            if (auto image = getImage(imageHandle))
+                            if (auto imageProperty =
+                                    viewModelInstance->propertyImage(
+                                        value.metaData.name))
                             {
-                                if (auto imageProperty =
-                                        viewModelInstance->propertyImage(
-                                            value.metaData.name))
+                                if (imageHandle == RIVE_NULL_HANDLE)
+                                {
+                                    imageProperty->value(nullptr);
+                                }
+                                else if (auto image = getImage(imageHandle))
                                 {
                                     imageProperty->value(image);
                                 }
@@ -2497,8 +2501,10 @@
                                         handle,
                                         requestId,
                                         CommandQueue::Message::viewModelError)
-                                        << "Could not find "
-                                           "image property at path "
+                                        << "Could not find image "
+                                        << imageHandle
+                                        << " to set for view model instance "
+                                           "when setting property with path "
                                         << value.metaData.name;
                                 }
                             }
@@ -2509,21 +2515,25 @@
                                     handle,
                                     requestId,
                                     CommandQueue::Message::viewModelError)
-                                    << "Could not find image " << imageHandle
-                                    << " to set for view model instance when "
-                                       "setting property with path "
+                                    << "Could not find "
+                                       "image property at path "
                                     << value.metaData.name;
                             }
                             break;
                         }
                         case DataType::artboard:
                         {
-                            if (auto bindableArtboard =
-                                    getBindableArtboard(artboadHandle))
+                            if (auto artboardProperty =
+                                    viewModelInstance->propertyArtboard(
+                                        value.metaData.name))
                             {
-                                if (auto artboardProperty =
-                                        viewModelInstance->propertyArtboard(
-                                            value.metaData.name))
+                                if (artboardHandle == RIVE_NULL_HANDLE)
+                                {
+                                    artboardProperty->value(nullptr);
+                                }
+                                else if (auto bindableArtboard =
+                                             getBindableArtboard(
+                                                 artboardHandle))
                                 {
                                     artboardProperty->value(bindableArtboard);
                                 }
@@ -2534,8 +2544,10 @@
                                         handle,
                                         requestId,
                                         CommandQueue::Message::viewModelError)
-                                        << "Could not find "
-                                           "artboard property at path "
+                                        << "Could not find artboard "
+                                        << artboardHandle
+                                        << " to set for view model instance "
+                                           "when setting property with path "
                                         << value.metaData.name;
                                 }
                             }
@@ -2546,10 +2558,8 @@
                                     handle,
                                     requestId,
                                     CommandQueue::Message::viewModelError)
-                                    << "Could not find artboard "
-                                    << artboadHandle
-                                    << " to set for view model instance when "
-                                       "setting property with path "
+                                    << "Could not find "
+                                       "artboard property at path "
                                     << value.metaData.name;
                             }
                             break;
diff --git a/tests/unit_tests/runtime/command_queue_test.cpp b/tests/unit_tests/runtime/command_queue_test.cpp
index 25a02f8..a4401e9 100644
--- a/tests/unit_tests/runtime/command_queue_test.cpp
+++ b/tests/unit_tests/runtime/command_queue_test.cpp
@@ -1978,6 +1978,32 @@
             CHECK(imageProperty->testing_value() == image);
         });
 
+    // Setting a null image handle should clear the property.
+    commandQueue->setViewModelInstanceImage(tester.m_handle,
+                                            "Test Image",
+                                            RIVE_NULL_HANDLE);
+
+    commandQueue->runOnce([handle = tester.m_handle](CommandServer* server) {
+        auto viewModel = server->getViewModelInstance(handle);
+        CHECK(viewModel != nullptr);
+        auto imageProperty = viewModel->propertyImage("Test Image");
+        CHECK(imageProperty != nullptr);
+        CHECK(imageProperty->testing_value() == nullptr);
+    });
+
+    // Setting a null artboard handle should clear the property.
+    commandQueue->setViewModelInstanceArtboard(tester.m_handle,
+                                               "Test Artboard",
+                                               RIVE_NULL_HANDLE);
+
+    commandQueue->runOnce([handle = tester.m_handle](CommandServer* server) {
+        auto viewModel = server->getViewModelInstance(handle);
+        CHECK(viewModel != nullptr);
+        auto artboardProperty = viewModel->propertyArtboard("Test Artboard");
+        CHECK(artboardProperty != nullptr);
+        CHECK(artboardProperty->testing_value() == nullptr);
+    });
+
     // We should set / get in order as it goes through the list.
     for (int i = 0; i < 10; ++i)
     {