The Communist
The Communist2w ago

Failed to set model on component on application quit.

I get the following errors occationally when unplaying in Unity. Failed to set model on component (1:DrinkCoaster-112 (DrinkCoasterController)). UnityEngine.Debug:LogError (object) Normal.Realtime.RealtimeView:BindModelsToComponentMap (Normal.Realtime.ImmutableModelCollection,Normal.Realtime.RealtimeComponentMa this is then followed by a bunch of null references on realtime objects. I am not sure why it is only occationally it seems like something might not be tearing down correctly and I get the null references because my code is still trying to access the networked variables?
Just looking to see if anyone has some tips or ideas on what could cause this. Thanks
6 Replies
kapa.ai
kapa.ai2w ago
Hi @brian. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This error is related to NormalVR's Normcore networking system and occurs during the Unity application's shutdown process. The issue you're experiencing is likely due to the order in which objects are being destroyed when the application is quitting. Based on the information provided in the knowledge sources, here are some insights and suggestions: 1. Timing of destruction: The error suggests that there's an attempt to set a model on a component (DrinkCoasterController) when the application is quitting. This could be because some objects are being destroyed before others, leading to null references. 2. RealtimeView and RealtimeComponents: The error mentions RealtimeView, which is responsible for managing RealtimeComponents. During the shutdown process, these components might be getting destroyed in an unexpected order. 3. Cleanup process: Normcore has its own cleanup process for RealtimeViews and RealtimeComponents. The occasional nature of the error might be due to race conditions during this cleanup. To address this issue, you could try the following: 1. Check component initialization: Ensure that your DrinkCoasterController and other RealtimeComponents are properly initialized and that they're not trying to access Realtime models after the application has started quitting. 2. Use connection status checks: Before accessing networked variables, check if the Realtime instance is still connected. You can do this by checking realtime.connected or using the didConnectToRoom event as mentioned in the Realtime Common Questions documentation. 3. Implement proper teardown: Make sure your custom components have proper teardown methods that unsubscribe from events and clear any references when the object is being destroyed. 4. Check for circular references: Ensure there are no circular references between your RealtimeComponents that might be causing issues during destruction. 5. Use OnApplicationQuit: Implement the OnApplicationQuit method in your MonoBehaviours to properly clean up Normcore-related resources before the application fully shuts down. If the issue persists after trying these suggestions, it might be worth reaching out to the Normcore community on their Discord for more specific assistance, as mentioned in their documentation. Remember that occasional errors during application shutdown, while not ideal, are often less critical than runtime errors. However, it's still good practice to try and resolve them to ensure clean application termination. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@478244499353501696> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Mechabit
Mechabit2w ago
I get this when I have singletons that spawn an instance when there isn't one. Stopping the editor causes a race condition where sometimes it gets destroyed and then reinstantiated
The Communist
The CommunistOP2w ago
It does seem to happen when I spawn in another realtime object and then stop the editor. Is there a good fix for this issue? Or not really an issue because its editor only?
Mechabit
Mechabit2w ago
it doesn't matter to the player but you'll want to get rid of the errors if you're using error tracking in unity if it's the singletons case you can get around it by checking if the app is quitting and preventing it from instantiating a new one
The Communist
The CommunistOP2w ago
Well all of the objects throwing the errors already exist in the scene already. I do not get the failure to set model on componenet referencing the objects I spawn in.

Did you find this page helpful?