Skip to content

Component serialization can crash or disconnect UnityMCP when reading Photon Fusion components #1128

@cyanxwh

Description

@cyanxwh

Summary

Reading GameObject or prefab component properties through UnityMCP can crash the Unity Editor or disconnect the UnityMCP session when the target contains Photon Fusion NetworkBehaviour components.

Photon Fusion is a popular Unity multiplayer game development framework used by many real-time multiplayer projects. Because Fusion components are commonly attached to player rigs, networked interactables, projectiles, and other gameplay prefabs, this issue can block UnityMCP inspection workflows in a broad class of multiplayer Unity projects.

Photon Fusion IL weaving injects fields/properties with unsafe internal types such as Fusion.NetworkBehaviourBuffer, Fusion.NetworkBehaviourCallbackBuffer, Fusion.Networked+Internals, and Fusion.Changed<T>. These types can be reached by the current reflection-based component serializer and are not safe to access or serialize.

Impact

This affects UnityMCP workflows that inspect scene objects or prefabs containing Fusion components, including:

  • Fusion.NetworkObject
  • Fusion.NetworkTransform
  • Fusion.Addons.Physics.NetworkRigidbody3D
  • Fusion.XR.Host.Rig.NetworkRig
  • Project-specific NetworkBehaviour subclasses

Depending on the object and session state, the symptom can be an Editor crash or a UnityMCP session disconnect while awaiting the serialization result.

Expected Behavior

UnityMCP should skip unsafe Fusion-injected fields/properties and continue serializing safe component data.

Actual Behavior

UnityMCP may attempt to reflect and serialize unsafe Fusion-injected types, causing instability when accessing Fusion-related components.

Proposed Fix

Before reading component fields/properties, detect and skip unsafe types, including:

  • known Fusion IL-weaved unsafe types
  • generic containers wrapping those types
  • arrays wrapping those types
  • pointer/by-ref/ref-like types

A regression test should cover direct and nested unsafe Fusion-like types.

Validation

A fix was validated with:

  • Unity 2022.3.62f1 EditMode targeted test
  • Unity 6000.0.41f1 EditMode targeted test
  • Manual UnityMCP validation against a real Photon Fusion project, including prefab-stage reads and scene-instantiated prefab reads

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions