PUN works in editor, but not in the build

I just created a empty project in Unity 2019.4.3 (LTS) and imported the PUN 2 from asset store. The example scenes works when I run in the editor, but not when I test it in a build. below is a log file from a windows build

Mono path[0] = 'C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Managed'
Mono config path = 'C:/GameBuildFolder/PhotonTest/Desktop/MonoBleedingEdge/etc'
PlayerConnection initialized from C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55145
Multi-casting "[IP] 192.168.0.61 [Port] 55145 [Flags] 2 [Guid] 3444603142 [EditorId] 3066427587 [Version] 1048832 [Id] WindowsPlayer(DESKTOP-5U4OQH4) [Debug] 0 [PackageName] WindowsPlayer [ProjectName] PhotonTest" to [225.0.0.222:54997]...
Started listening to [0.0.0.0:55145]
PlayerConnection already initialized - listening to [0.0.0.0:55145]
Initialize engine version: 2019.4.3f1 (f880dceab6fe)
[Subsystems] Discovering subsystems at path C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/UnitySubsystems
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: NVIDIA GeForce GTX 1060 6GB (ID=0x1c03)
Vendor: (null)
VRAM: 3072 MB
Driver: 27.21.14.5148
Begin MonoManager ReloadAssembly
- Completed reload, in 0.216 seconds
D3D11 device created for Microsoft Media Foundation video decoding.
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonCryptoPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonCryptoPlugin.dll
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonCryptoPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonCryptoPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonCryptoPlugin.dll
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonCryptoPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonSocketPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonSocketPlugin.dll
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonSocketPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonSocketPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonSocketPlugin.dll
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonSocketPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonEncryptorPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonEncryptorPlugin.dll
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/PhotonEncryptorPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonEncryptorPlugin
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonEncryptorPlugin.dll
Fallback handler could not load library C:/GameBuildFolder/PhotonTest/Desktop/PhotonTest_Data/Mono/libPhotonEncryptorPlugin
<RI> Initializing input.

<RI> Input initialized.

<RI> Initialized touch support.

UnloadTime: 1.501000 ms
Unloading 7 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 2.657700 ms
System memory in use before: 39.0 MB.
System memory in use after: 38.8 MB.

Unloading 11 unused Assets to reduce memory usage. Loaded Objects now: 768.
Total: 0.536000 ms (FindLiveObjects: 0.099300 ms CreateObjectMapping: 0.015900 ms MarkObjects: 0.399900 ms DeleteObjects: 0.020300 ms)

Unloading 2 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 0.456400 ms
System memory in use before: 39.2 MB.
System memory in use after: 39.2 MB.

Unloading 8 unused Assets to reduce memory usage. Loaded Objects now: 1116.
Total: 0.714700 ms (FindLiveObjects: 0.108500 ms CreateObjectMapping: 0.019800 ms MarkObjects: 0.556400 ms DeleteObjects: 0.029400 ms)

Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 0.600400 ms
System memory in use before: 39.3 MB.
System memory in use after: 39.2 MB.

Unloading 9 unused Assets to reduce memory usage. Loaded Objects now: 768.
Total: 0.560600 ms (FindLiveObjects: 0.093700 ms CreateObjectMapping: 0.015100 ms MarkObjects: 0.432300 ms DeleteObjects: 0.018800 ms)

JoinRandomRoom failed. Client is on NameServer (must be Master Server for matchmaking) but not ready for operations (State: Disconnecting). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Photon.Pun.PhotonNetwork:JoinRandomRoom(Hashtable, Byte, MatchmakingMode, TypedLobby, String, String[]) (at C:\UnityProject\PhotonTest\PhotonTest\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetwork.cs:1598)
Photon.Pun.PhotonNetwork:JoinRandomRoom() (at C:\UnityProject\PhotonTest\PhotonTest\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetwork.cs:1532)
Photon.Pun.Demo.PunBasics.Launcher:Connect() (at C:\UnityProject\PhotonTest\PhotonTest\Assets\Photon\PhotonUnityNetworking\Demos\PunBasics-Tutorial\Scripts\Launcher.cs:111)
UnityEngine.Events.InvokableCall:Invoke()
UnityEngine.Events.UnityEvent:Invoke()
UnityEngine.UI.Button:Press() (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Button.cs:68)
UnityEngine.UI.Button:OnPointerClick(PointerEventData) (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:261)
UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse(PointerEventData, GameObject) (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:195)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:644)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:552)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:532)
UnityEngine.EventSystems.StandaloneInputModule:Process() (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:289)
UnityEngine.EventSystems.EventSystem:Update() (at C:\Program Files\Unity3D\2019.4.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\EventSystem.cs:377)

(Filename: C:/UnityProject/PhotonTest/PhotonTest/Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs Line: 1598)

Setting up 3 worker threads for Enlighten.
Thread -> id: 91c -> priority: 1
Thread -> id: 1c74 -> priority: 1
Thread -> id: 3354 -> priority: 1
##utp:{"type":"MemoryLeaks","version":2,"phase":"Immediate","time":1596486096828,"processId":10448,"allocatedMemory":9989,"memoryLabels":[{"Permanent":24},{"NewDelete":220},{"Thread":136},{"Manager":1404},{"VertexData":336},{"GfxDevice":4392},{"GfxThread":12},{"Physics":40},{"Serialization":24},{"String":149},{"DynamicArray":2352},{"PoolAlloc":32},{"Sprites":52},{"GI":184},{"VR":1128},{"Subsystems":4294966800}]}

Comments

  • Thanks for the report.
    We found this Unity issue too late but fixed it with PUN 2.20.1.

    Some background: When you use the attribute RuntimeInitializeOnLoadMethod on a method that creates a GameObject, the Editor behaves differently than the build. In the build, the GameObject gets destroyed (for unknown reasons) and this cause PUN not to run it's update loop.

    As said: Fixed in PUN 2.20.1, available now.