Spawned Prefabs with Disabled Game Objects inside break syncing if deleted via DestroyObject
closed
Eremite
I noticed while testing a world that occasionally a lot of triggers in the game would break; for example pens would no longer write, objects could no longer be deleted via OnEnterCollider->DestroyObject triggers, etc.
After much testing and heartache, I found that it was being caused by deleting a prefab with a disabled game object inside of it.
It did not matter if the prefab existed at world startup, or if it was a spawned prefab. Both would break the world.
~~ Replication ~~
I have a prefab that looks something like:
Object
--Enabled ON button
--Disabled OFF button
--Several Other Child Objects
Trigger: OnEnterCollider (TrashLayer) -> DestroyObject (parent of prefab)
Once this object is trashed, it seems that many triggers were broken; a perusal of the vrc output log found this error appearing when I would try activating one of the triggers (as an example) :
---
[Log:6/16/2018 7:01:48 PM] Assets/_Worlds/Prefabs/Markers/large_marker_orange.prefab (Dynamic Clone 858113:1004) triggered AnimationBool
[Log:6/16/2018 7:01:48 PM] Replicating [3EC00000000 AnimationBool/AlwaysUnbuffered w: 1 s: draw i: 0 f: 0 b: False B: 0 p: :3EC00000000/Emitter1]
[Exception:6/16/2018 7:01:48 PM] NullReferenceException
VRC_EventDispatcherRFC.BPMPABEHGGC (VRCSDK2.VrcEvent ADINHJNPBBM)
VRC_EventDispatcherRFC.DECODOLHNFL (VRCSDK2.VrcEvent ADINHJNPBBM, VrcBroadcastType FDIDEPPNDBB, Int32 AIPPAANABKF, Single OMOHDCODLIA)
VRC_EventDispatcherRFC.TriggerEvent (VRCSDK2.VRC_EventHandler KNMJAPDEEMI, VRCSDK2.VrcEvent ADINHJNPBBM, VrcBroadcastType FDIDEPPNDBB, Int32 AIPPAANABKF, Single OMOHDCODLIA)
VRC_EventLog.FMLNFNLECHI (.NDPOEEFOCPM HEEJDHOMCEG, VRC.Player ICOPGBDHELL)
VRC.EventReplicator`2[EventType,EventEqualityComparerType].OKCHENJJFCC (.EventType HEEJDHOMCEG, Boolean GJCKIFLLOKK, .NALJHKLMIHL ICOPGBDHELL)
VRC.EventReplicator`2[EventType,EventEqualityComparerType].ProcessEvent (.EventType HEEJDHOMCEG, .NALJHKLMIHL ICOPGBDHELL)
VRC_EventLog+EventReplicator.ProcessEvent (.NDPOEEFOCPM HEEJDHOMCEG, .NALJHKLMIHL ICOPGBDHELL)
VRC_EventLog.LogEvent (VRCSDK2.VRC_EventHandler JGENKKDMBGF, VRCSDK2.VrcEvent EGKJDMANNLA, Int64 GJAIGDGIFOA, VrcBroadcastType FDIDEPPNDBB, Int32 AIPPAANABKF, Single OMOHDCODLIA)
VrcSdk2Interface.GKJHHJHODMB (VRCSDK2.VRC_EventHandler JGENKKDMBGF, VRCSDK2.VrcEvent EGKJDMANNLA, Int64 GJAIGDGIFOA, VrcBroadcastType FDIDEPPNDBB, Int32 AIPPAANABKF, Single OMOHDCODLIA)
VRCSDK2.VRC_EventHandler.InternalTriggerEvent (VRCSDK2.VrcEvent e, VrcBroadcastType broadcast, Int32 instagatorId, Single fastForward)
VRCSDK2.VRC_EventHandler.TriggerEvent (VRCSDK2.VrcEvent e, VrcBroadcastType broadcast, Int32 instagatorId, Single fastForward)
VRCSDK2.VRC_EventHandler.TriggerEvent (VRCSDK2.VrcEvent e, VrcBroadcastType broadcast, UnityEngine.GameObject instagator, Single fastForward)
VRCSDK2.VRC_Trigger+<ExecutionIterator>c__Iterator4.MoveNext ()
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
VRCSDK2.VRC_Trigger:ExecuteTrigger(TriggerEvent)
VRCSDK2.VRC_Trigger:ExecuteTriggerType(TriggerType)
VRCSDK2.VRC_Trigger:Trigger(GameObject, TriggerType)
VRCHandGrasper:PKPMEPLIIIO(TriggerType)
VRCHandGrasper:CILCGCEJGIP(Boolean)
VRCHandGrasper:EDANBPJOJCO()
VRCHandGrasper:Update()
Log In
Tupper - VRChat Head of Community
closed
Closing due to age, please make a new post if it is still relevant.
Noe
Merged in a post:
Inactive child with VRC_Trigger in dynamic prefab crushes its prefab if an instance is destroyed
naqtn
Reproduce steps:
- Add a object to scene. Add child object, add VRC_Trigger to child, deactivate this child.
- Add VRC_Trigger to parent. Setup OnInteract trigger to destroy itself with Destroy action.
- Make a prefab from this object.
- Add another object to spawn this prefab (with OnInteract trigger and SpawnObject action)
- Run. Spawn a object and destroy it by interact. Again spawn. This time, destroy does not work. You can see NullReferenceException on the log.
----
Additional info:
* If using this prefab as initially placed object in the scene, this issue doesn't occur.
* If first object is initially placed object, and second one is spawned, this issue doesn't occur.
* After destroy action doesn't work, placed object destroy action works.
* So only spawnd object destories something in its prefab.
* Content of child VRC_Trigger is not matter.
* I guess uninitialized VRC_Trigger crushes template instance holding in DynamicPrefab.
----
Abstruct in Japanese:
概要:OnInteract で自身を Destroy するプレハブが inactive な子に VRC_Trigger を備える場合に、SpawnObject でこのプレハブを使用すると、二回目以降の OnInteract 操作で NullReferenceException が発生して Destroy 処理を完了できない。そのようになった後も、スポーンでなくワールドにあらかじめ配置していたオブジェクトの Destroy は実行できる。おそらく、一つ目の Spawn で生成したインスタンスの Destroy が未初期化の VRC_Trigger を通して DynamicPrefab の中のインスタンスを壊している。
----
Log:
2018.10.28 19:12:31 Log - [VRC_TriggerInternal] 28.09733 Cube via OnInteract executing [SpawnObject (False, 0.000, 0, "SpawnPos", Assets/SelfDestroyPrefabTest.prefab, 0)]
2018.10.28 19:12:31 Log - [VRC_EventDispatcherRFC] SpawnObject:Assets/SelfDestroyPrefabTest.prefab on (SpawnPos)
2018.10.28 19:12:31 Log - [VRC_EventDispatcherRFC] SendRPC SceneEventHandlerAndInstantiator:_InstantiateObject for VRCPlayer[Local] 1 and 85 bytes
2018.10.28 19:12:31 Log - [VRC_EventDispatcherRFC] SendRPC SceneEventHandlerAndInstantiator:_SendOnSpawn for VRCPlayer[Local] 1 and 8 bytes
2018.10.28 19:12:34 Log - [VRC_TriggerInternal] 30.81635 Assets/SelfDestroyPrefabTest.prefab (Dynamic Clone 639489:100003) via OnInteract executing [DestroyObject (False, 0.000, 0, "Assets/SelfDestroyPrefabTest.prefab (Dynamic Clone 639489:100003)", , 0)]
2018.10.28 19:12:34 Log - [VRC_EventDispatcherRFC] SendRPC SceneEventHandlerAndInstantiator:_DestroyObject for VRCPlayer[Local] 1 and 8 bytes
2018.10.28 19:12:34 Log - AmplitudeAPI: upload finished, successfully posted 5 events
2018.10.28 19:12:36 Log - [VRC_TriggerInternal] 32.80692 Cube via OnInteract executing [SpawnObject (False, 0.000, 0, "SpawnPos", Assets/SelfDestroyPrefabTest.prefab, 0)]
2018.10.28 19:12:36 Log - [VRC_EventDispatcherRFC] SpawnObject:Assets/SelfDestroyPrefabTest.prefab on (SpawnPos)
2018.10.28 19:12:36 Log - [VRC_EventDispatcherRFC] SendRPC SceneEventHandlerAndInstantiator:_InstantiateObject for VRCPlayer[Local] 1 and 85 bytes
2018.10.28 19:12:36 Log - [VRC_EventDispatcherRFC] SendRPC SceneEventHandlerAndInstantiator:_SendOnSpawn for VRCPlayer[Local] 1 and 8 bytes
2018.10.28 19:12:37 Log - [VRC_TriggerInternal] 34.56141 Assets/SelfDestroyPrefabTest.prefab (Dynamic Clone 748289:100004) via OnInteract executing [DestroyObject (False, 0.000, 0, "Assets/SelfDestroyPrefabTest.prefab (Dynamic Clone 748289:100004)", , 0)]
2018.10.28 19:12:37 Exception - NullReferenceException
VRC_EventDispatcherRFC.KMMBPFIIEBF (VRCSDK2.VrcEvent HCHPAGCGFBF)
VRC_EventDispatcherRFC.NHCKFCLCBAK (VRCSDK2.VrcEvent HCHPAGCGFBF, VrcBroadcastType LBIKHAMFELH, Int32 OLKPGCMEBJE, Single ACPLOOBMIFN)
VRC_EventDispatcherRFC.TriggerEvent (VRCSDK2.VRC_EventHandler NLFCBCGMKCH, VRCSDK2.VrcEvent HCHPAGCGFBF, VrcBroadcastType LBIKHAMFELH, Int32 OLKPGCMEBJE, Single ACPLOOBMIFN)
VRC_EventLog.LogEvent (VRCSDK2.VRC_EventHandler AIGDPDDKFFJ, VRCSDK2.VrcEvent AMHPKELPCMI, Int64 OIAPPBGEPEE, VrcBroadcastType LBIKHAMFELH, Int32 OLKPGCMEBJE, Single ACPLOOBMIFN)
VrcSdk2Interface.GMBEGHAHDOB (VRCSDK2.VRC_EventHandler AIGDPDDKFFJ, VRCSDK2.VrcEvent AMHPKELPCMI, Int64 OIAPPBGEPEE, VrcBroadcastType LBIKHAMFELH, Int32 OLKPGCMEBJE, Single ACPLOOBMIFN)
VRCSDK2.VRC_EventHandler.InternalTriggerEvent (VRCSDK2.VrcEvent e, VrcBroadcastType broadcast, Int32 instagatorId, Single fastForward)
VRCSDK2.VRC_EventHandler.TriggerEvent (VRCSDK2.VrcEvent e, VrcBroadcastType broadcast, Int32 instagatorId, Single fastForward)
VRCSDK2.VRC_EventHandler.TriggerEvent (VRCSDK2.VrcEvent e, VrcBroadcastType broadcast, UnityEngine.GameObject instagator, Single fastForward)
VRC_TriggerInternal+DGMLABLOGBM.MoveNext ()
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
VRC_TriggerInternal:HFGFIHBGCCP(TriggerEvent)
VRCSDK2.VRC_Trigger:ExecuteTriggerType(TriggerType)
VRCSDK2.VRC_Trigger:Interact()
InteractivePlayer:Update()
Eremite
May be related to this? https://vrchat.canny.io/bug-reports/p/spawned-prefabs-with-disabled-game-objects-inside-break-syncing-if-deleted-via-d
My workaround was to destroy child objects first, then the parent object.
naqtn
Eremite: Oh yes, it's identical. And thanks for workaround.
Eremite
As a note for anyone else coming across this error, the workaround that I came up with for now is to have the DestroyObject call delete all the disabled objects within the prefab
first
, then delete the parent object. eg: DestroyObject:
Targets:
--Disabled OFF button
--Object
K
Katerina
Eremite: Thank you! Seriously. You saved me, I spent so much time debugging this!