Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
738 stars 186 forks source link

[BUG]: Plugin crashes during load with NVIDIA gpu that doesn't support NVDEC #1006

Open jonitee opened 7 months ago

jonitee commented 7 months ago

Package version

3.0.0-pre.7

Environment

* OS: Windows 10
* Unity version: 2021.3.2f1 (d6360bedb9a0)

Steps To Reproduce

  1. Have a device with NVIDIA gpu that doesn't support NVDEC
  2. Include WebRTC pre7 as package on a Unity project
  3. Try to open the project from Unity hub
  4. Unity hub crashes during load-up

Current Behavior

Whole Unity project crashes when trying to start a project that has included the WebRTC package and the device has a NVIDIA gpu that doesn't support NVDEC. The crashing happens when starting from the Unity hub and also when trying to start compiled executable file.

Expected Behavior

The project should compile and the parts of the software that don't support the hardware could be disabled during run-time.

Anything else?

client_crash_log.txt

karasusan commented 7 months ago

@jonitee The GPU card NVIDIA T500 doesn't support NVENC/NVDEC. We can't reproduce the issue because we don't have the card. I read your crash log, however, I couldn't find the line in our code which is cause of the crash. I could find if you have a crash log using the plugin of debug build. If you can cooperate me, I can share you the plugin for debug.

Grit007 commented 7 months ago

@karasusan I have the seem problems in NVIDIA A300 card
298261700019393_ pic

karasusan commented 7 months ago

@Grit007 Oh, it's so helpful to us. This log shows this line is throwing an exception. https://github.com/Unity-Technologies/com.unity.webrtc/blob/main/Plugin~/NvCodec/NvCodec/NvEncoder/NvEncoder.cpp#L54C4-L54C89

Grit007 commented 7 months ago

@Grit007 Oh, it's so helpful to us. This log shows this line is throwing an exception. https://github.com/Unity-Technologies/com.unity.webrtc/blob/main/Plugin~/NvCodec/NvCodec/NvEncoder/NvEncoder.cpp#L54C4-L54C89

How to fix it, Can you give some tips?I'm not sure whether it's a NVIDIA card problem or webrtc package problem. this is NVIDIA's Video Encode and Decode GPU Support Matrix: https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new

karasusan commented 7 months ago

@Grit007 I could't find A300 in the support matrix. It looks the graphic card problem.

Grit007 commented 7 months ago

@Grit007 I could't find A300 in the support matrix. It looks the graphic card problem.

Sorry, the NVIDIA card is A30 ...
image

jonitee commented 7 months ago

@Grit007 Oh, it's so helpful to us. This log shows this line is throwing an exception. https://github.com/Unity-Technologies/com.unity.webrtc/blob/main/Plugin~/NvCodec/NvCodec/NvEncoder/NvEncoder.cpp#L54C4-L54C89

Good to see that this might be fixable on software level. We were hoping that even though the NVIDIA GPU that we have doesn't support the NVENC/NVDEC, we could still at least compile the WebRTC plugin and during run-time initialize the objects in the Unity application that use the codec, if we have a compatible GPU available. We run to this issue with computers to which we ship our application but we don't have control over the hardware causing the application crashing during initialization.

@karasusan if you still need debug help, I'm happy to help

karasusan commented 7 months ago

@jonitee I'm glad to hear that you can help us. Let you know when I prepare the fixed version.

karasusan commented 7 months ago

memo: WRS-503

kevindude6 commented 7 months ago

I have been encountering a related issue, so I thought my information might help as well. The Linux version of my app crashes on startup. We are using an Nvidia Rtx 3070TI, which has NVENC support. I suspect that in this case, we are already using all of our NVENC sessions / memory on other processes, so the unity app can not open a session and crashes.

However, I don't use NVENC with the webrtc library. I use the webrtc library only for decoding video. So I don't think the NVENC session even needs to be opened.

terminate called after throwing an instance of 'NVENCException'
  what():  NvEncoder : m_nvenc.nvEncOpenEncodeSessionEx(&encodeSessionExParams, &hEncoder) returned error 10 at /home/bokken/build/output/Unity-Technologies/com.unity.webrtc/Plugin~/NvCodec/NvCodec/NvEncoder/NvEncoder.cpp:54

Caught fatal signal - signo:6 code:-6 errno:0 addr:0x3e800007512
Obtained 29 stack frames.

Occurs on Ubuntu 20.04, Unity app built with 2022.3.5f1, WebRTC package version 3.0.0-pre.6 Built using IL2CPP

karasusan commented 6 months ago

PR #1009 should fix this issue. If you can download and check whether this issue is reproduced or not, it helps us. https://drive.google.com/file/d/1ySSY9b0F2d4xL_T3af3myJKDr0C0EOo8/view?usp=sharing

Grit007 commented 6 months ago

PR #1009 should fix this issue. If you can download and check whether this issue is reproduced or not, it helps us. https://drive.google.com/file/d/1ySSY9b0F2d4xL_T3af3myJKDr0C0EOo8/view?usp=sharing

@karasusan hi, I run the new package in unity urp pipeline on my Linux centOS environment, now the player run normal and not crash. this is the Player.log file. Although not crash,the log file seems have some problems, can you tell me some tips about the log file? Player.log my NVIDIA card is A30 which not support NVENC and the scene my run is MediaStream sample scene in the package.

karasusan commented 5 months ago

@Grit007 We tested Ubuntu 20.24 but not CentOS. The error in Player.log show the reason of crash is not NVIDIA driver.

Mono path[0] = '/home/work/testnewWebRTC/test_Data/Managed'
Mono config path = '/home/work/testnewWebRTC/test_Data/MonoBleedingEdge/etc'
Preloaded 'lib_burst_generated.so'
Unable to preload the following plugins:
    libwebrtc.so
Unable to load player prefs
Plugins: Couldn't open /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so, error: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so)
Plugins: Couldn't open /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so, error: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so)
Desktop is 0 x 0 @ 0 Hz

The reason is that GLIBC_2.27 is not found on your environment.

Grit007 commented 5 months ago

@Grit007 We tested Ubuntu 20.24 but not CentOS. The error in Player.log show the reason of crash is not NVIDIA driver.

Mono path[0] = '/home/work/testnewWebRTC/test_Data/Managed'
Mono config path = '/home/work/testnewWebRTC/test_Data/MonoBleedingEdge/etc'
Preloaded 'lib_burst_generated.so'
Unable to preload the following plugins:
  libwebrtc.so
Unable to load player prefs
Plugins: Couldn't open /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so, error: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so)
Plugins: Couldn't open /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so, error: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/work/testnewWebRTC/test_Data/Plugins/libwebrtc.so)
Desktop is 0 x 0 @ 0 Hz

The reason is that GLIBC_2.27 is not found on your environment.

got it, thanks reply

jonitee commented 4 months ago

Hi!

@karasusan, I had now time to test the fix that was put into the develop for the package. Unfortunately, the loading of the package is still crashing. Although, the issue is now in different place. I have attached crash log from the Unity Hub to this message.

client_crash_log.txt

I think now this might be the interesting part of the log

Finished compiling graph: 379 nodes, 4986 flattened edges (4986 ToBuild, 0 ToUse), maximum node priority 150
[164/378    0s] WriteText Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.rsp
[171/378    0s] WriteText Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.Editor.dll.mvfrm.rsp
[174/378    0s] WriteText Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.dll.mvfrm.rsp
[176/378    0s] WriteText Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.Editor.rsp
[367/378    0s] MovedFromExtractor Library/Bee/artifacts/mvdfrm/Unity.EditorCoroutines.Editor.ref.dll_34ED10A34098B2DB.mvfrm
[368/378    0s] MovedFromExtractorCombine Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.dll.mvfrm
[369/378    0s] Csc Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.dll (+2 others)
[370/378    0s] CopyFiles Library/ScriptAssemblies/Unity.WebRTC.pdb
[371/378    0s] MovedFromExtractor Library/Bee/artifacts/mvdfrm/Unity.WebRTC.ref.dll_CF837AC6DB98867B.mvfrm
[372/378    0s] CopyFiles Library/ScriptAssemblies/Unity.WebRTC.dll
[373/378    0s] MovedFromExtractorCombine Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.Editor.dll.mvfrm
[374/378    0s] Csc Library/Bee/artifacts/1900b0aE.dag/Unity.WebRTC.Editor.dll (+2 others)
[375/378    0s] CopyFiles Library/ScriptAssemblies/Unity.WebRTC.Editor.pdb
[376/378    0s] CopyFiles Library/ScriptAssemblies/Unity.WebRTC.Editor.dll
*** Tundra build success (1.42 seconds), 14 items updated, 378 evaluated
Reloading assemblies after forced synchronous recompile.
Begin MonoManager ReloadAssembly
Symbol file LoadedFromMemory doesn't match image <project/path>\Library\PackageCache\com.unity.visualscripting@1.7.6\Editor\VisualScripting.Core\Dependencies\YamlDotNet\Unity.VisualScripting.YamlDotNet.dll
Symbol file LoadedFromMemory doesn't match image <project/path>\Library\PackageCache\com.unity.visualscripting@1.7.6\Editor\VisualScripting.Core\Dependencies\DotNetZip\Unity.VisualScripting.IonicZip.dll
Native extension for WindowsStandalone target not found
Refreshing native plugins compatible for Editor in 90.78 ms, found 4 plugins.
Preloading 1 native plugins for Editor in 148.81 ms.
[MODES] ModeService[none].Initialize
[MODES] ModeService[none].LoadModes
[MODES] Loading mode Default (0) for mode-current-id-My project
Mono: successfully reloaded assembly
Crash!!!