Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
739 stars 185 forks source link

[BUG]: #864

Closed philip-lamb closed 1 year ago

philip-lamb commented 1 year ago

Package version

3.0.0-pre.2

Environment

* OS: Windows 10.
* Unity version: 2021.3.2f1

During opening of a project using WebRTC v3.0.0-pre.2 on a headless CI system running Windows 10, the WebRTC plugin crashes during plugin initialization.

Note that this is not at runtime, it is at the time the Unity project is loaded into the Unity Editor.

It appears that since in 3.0.0-pre.2 WebRTC.Initialize() is run on plugin load, on this system during the BUILD there is no graphics context available, and the plugin load fails.

Steps To Reproduce

Open a project using WebRTC v3.0.0-pre.2 on a headless CI system running Windows 10.

Relevant part of editor log, showing crash and backtrace

2022-12-16T04:21:37.8856750Z Begin MonoManager ReloadAssembly
2022-12-16T04:21:42.0918659Z Mono: successfully reloaded assembly
2022-12-16T04:21:42.1131710Z 
2022-12-16T04:21:42.1133000Z =================================================================
2022-12-16T04:21:42.1134243Z    Native Crash Reporting
2022-12-16T04:21:42.1134639Z =================================================================
2022-12-16T04:21:42.1135046Z Got a UNKNOWN while executing native code. This usually indicates
2022-12-16T04:21:42.1135446Z a fatal error in the mono runtime or one of the native libraries 
2022-12-16T04:21:42.1135783Z used by your application.
2022-12-16T04:21:42.1136116Z =================================================================
2022-12-16T04:21:42.1136305Z 
2022-12-16T04:21:42.1136595Z =================================================================
2022-12-16T04:21:42.1136920Z    Managed Stacktrace:
2022-12-16T04:21:42.1137244Z =================================================================
2022-12-16T04:21:42.1137588Z      at <unknown> <0xffffffff>
2022-12-16T04:21:42.1137942Z      at Unity.WebRTC.NativeMethods:ContextCreate <0x00089>
2022-12-16T04:21:42.1138311Z      at Unity.WebRTC.Context:Create <0x00022>
2022-12-16T04:21:42.1138684Z      at Unity.WebRTC.WebRTC:InitializeInternal <0x0024a>
2022-12-16T04:21:42.1139102Z      at Unity.WebRTC.ContextManager:OnAfterAssemblyReload <0x00022>
2022-12-16T04:21:42.1139547Z      at UnityEditor.AssemblyReloadEvents:OnAfterAssemblyReload <0x0007f>
2022-12-16T04:21:42.1139961Z      at System.Object:runtime_invoke_void <0x0007c>
2022-12-16T04:21:42.1140346Z =================================================================
2022-12-16T04:21:42.2315046Z Received signal SIGSEGV
2022-12-16T04:21:47.6064012Z Obtained 28 stack frames
2022-12-16T04:21:47.6064804Z 0x00007fff09bd4285 (webrtc) GetUpdateTextureFunc
2022-12-16T04:21:47.6065498Z 0x00007fff09ba26bb (webrtc) GetUpdateTextureFunc
2022-12-16T04:21:47.6066155Z 0x00007fff09ba12aa (webrtc) GetUpdateTextureFunc
2022-12-16T04:21:47.6066843Z 0x00007fff09b939e6 (webrtc) ContextCreate
2022-12-16T04:21:47.6067830Z 0x000002147b875baa (Mono JIT Code) (wrapper managed-to-native) Unity.WebRTC.NativeMethods:ContextCreate (int)
2022-12-16T04:21:47.6069202Z 0x000002147b875a63 (Mono JIT Code) [Context.cs:71] Unity.WebRTC.Context:Create (int) 
2022-12-16T04:21:47.6070430Z 0x000002147b874b5b (Mono JIT Code) [WebRTC.cs:681] Unity.WebRTC.WebRTC:InitializeInternal (bool,bool,Unity.WebRTC.NativeLoggingSeverity) 
2022-12-16T04:21:47.6071682Z 0x000002147b8747e3 (Mono JIT Code) [Context.cs:31] Unity.WebRTC.ContextManager:OnAfterAssemblyReload () 
2022-12-16T04:21:47.6072779Z 0x000002147b870d30 (Mono JIT Code) UnityEditor.AssemblyReloadEvents:OnAfterAssemblyReload ()
2022-12-16T04:21:47.6073896Z 0x00000213e66f803d (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
2022-12-16T04:21:47.6074965Z 0x00007fff0f3be0a4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke 
2022-12-16T04:21:47.6075890Z 0x00007fff0f2fe744 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke 
2022-12-16T04:21:47.6076746Z 0x00007fff0f2fe8dc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke 
2022-12-16T04:21:47.6077549Z 0x00007ff68a36fd84 (Unity) scripting_method_invoke
2022-12-16T04:21:47.6078328Z 0x00007ff68a36a9a4 (Unity) ScriptingInvocation::Invoke
2022-12-16T04:21:47.6079206Z 0x00007ff68a33a261 (Unity) MonoManager::EndReloadAssembly
2022-12-16T04:21:47.6080146Z 0x00007ff68a3418d8 (Unity) MonoManager::ReloadAssembly
2022-12-16T04:21:47.6081017Z 0x00007ff68b275202 (Unity) LoadDomainAndUserAssemblies
2022-12-16T04:21:47.6081893Z 0x00007ff68b27547e (Unity) LoadInitAssemblies
2022-12-16T04:21:47.6082675Z 0x00007ff68b7207a1 (Unity) ImportOutOfDateAssets
2022-12-16T04:21:47.6083446Z 0x00007ff68b72c7f3 (Unity) RefreshInternalV2
2022-12-16T04:21:47.6084244Z 0x00007ff68b7361d1 (Unity) StopAssetImportingV2Internal
2022-12-16T04:21:47.6085037Z 0x00007ff68b72120d (Unity) InitialRefreshV2
2022-12-16T04:21:47.6087062Z 0x00007ff68af6c2b2 (Unity) Application::InitializeProject
2022-12-16T04:21:47.6087867Z 0x00007ff68b3c3e78 (Unity) WinMain
2022-12-16T04:21:47.6088614Z 0x00007ff68c6e582e (Unity) __scrt_common_main_seh
2022-12-16T04:21:47.6089416Z 0x00007fff3d777974 (KERNEL32) BaseThreadInitThunk
2022-12-16T04:21:47.6090340Z 0x00007fff3e15a2f1 (ntdll) RtlUserThreadStart

Current Behavior

A crash.

Expected Behavior

No crash.

Anything else?

Reverted to 3.0.0-pre.1 and re-instated WebRTC.Initialize() in my code and it works OK with no crash.

karasusan commented 1 year ago

@philip-lamb Hi, Could you try the 3.0.0-pre.3? I fixed the issue last week. https://github.com/Unity-Technologies/com.unity.webrtc/pull/862

philip-lamb commented 1 year ago

Thanks, that works.