SIGSEGV error and constant crashes
See original GitHub issueVersion
6.1.2
Details
I’ve been using your DLL library in my Unity project, and it usually works on and off. This was because of Youtube’s new streaming restrictions, but it seems that some time has passed, and you’ve found workarounds to that issue, as the latest version seems to get around it rather easily.
However, I have ran into another issue: constant crashes. The library works completely fine for a few videos, streaming them easily and perfectly for a few in a row or so. Then, unexpectedly, the library runs into a SIGSEGV and crashes the app. This happens with both IL2CPP and Mono compilation, using .NET 2.1 Standard, on both Android and Windows. I’ve included the crash logs below, and note that “MoveNext()” is simply the name of a function that calls your GetAsync and DownloadAsync functions.
=================================================================
Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at System.Object:__icall_wrapper_mono_marshal_isinst_with_cache <0x00078>
at System.Object:__castclass_with_cache <0x0007a>
at System.Runtime.CompilerServices.ConditionalWeakTable`2:TryGetValue <0x00172>
at System.Runtime.CompilerServices.ConditionalWeakTable`2:GetValue <0x000b2>
at System.Runtime.CompilerServices.ConditionalWeakTable`2:GetOrCreateValue <0x0023a>
at For`1:GetCache <0x00032>
at YoutubeExplode.Utils.Memo:Cache <0x0004a>
at YoutubeExplode.Bridge.PlayerStreamInfoExtractor:TryGetFramerate <0x000aa>
at <PopulateStreamInfosAsync>d__3:MoveNext <0x00d00>
at MoveNextRunner:InvokeMoveNext <0x00091>
at System.Threading.ExecutionContext:RunInternal <0x001dd>
at System.Threading.ExecutionContext:Run <0x0002a>
at MoveNextRunner:Run <0x000ea>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00039>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00064>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x00132>
at System.Threading.Tasks.Task:FinishContinuations <0x00352>
at System.Threading.Tasks.Task:FinishStageThree <0x00082>
at System.Threading.Tasks.Task`1:TrySetResult <0x000ca>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x000e2>
at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1:SetResult <0x00052>
at <TryGetContentLengthAsync>d__2:MoveNext <0x00552>
at MoveNextRunner:InvokeMoveNext <0x00091>
at System.Threading.ExecutionContext:RunInternal <0x001dd>
at System.Threading.ExecutionContext:Run <0x0002a>
at MoveNextRunner:Run <0x000ea>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00039>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00064>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x00132>
at System.Threading.Tasks.Task:FinishContinuations <0x00352>
at System.Threading.Tasks.Task:FinishStageThree <0x00082>
at System.Threading.Tasks.Task`1:TrySetResult <0x000e2>
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult <0x000d2>
at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1:SetResult <0x0008a>
at <HeadAsync>d__0:MoveNext <0x0036a>
at MoveNextRunner:InvokeMoveNext <0x00091>
at System.Threading.ExecutionContext:RunInternal <0x001dd>
at System.Threading.ExecutionContext:Run <0x0002a>
at MoveNextRunner:Run <0x000ea>
at <>c:<.cctor>b__7_0 <0x00039>
at WorkRequest:Invoke <0x00023>
at UnityEngine.UnitySynchronizationContext:Exec <0x0018a>
at UnityEngine.UnitySynchronizationContext:ExecuteTasks <0x0007a>
at System.Object:runtime_invoke_void <0x00084>
=================================================================
Received signal SIGSEGV
Obtained 64 stack frames
0x00007ffd970c9c73 (mono-2.0-bdwgc) [object.c:7472] mono_object_isinst_checked
0x00007ffd9705bdf5 (mono-2.0-bdwgc) [marshal.c:4119] mono_marshal_isinst_with_cache
0x00000212dde219d9 ((<unknown>))
0x00000213b1a19aab (Mono JIT Code) (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
0x0000021308299023 (Mono JIT Code) System.Runtime.CompilerServices.ConditionalWeakTable`2<TKey_REF, TValue_REF>:TryGetValue (TKey_REF,TValue_REF&)
0x0000021308298d33 (Mono JIT Code) System.Runtime.CompilerServices.ConditionalWeakTable`2<TKey_REF, TValue_REF>:GetValue (TKey_REF,System.Runtime.CompilerServices.ConditionalWeakTable`2/CreateValueCallback<TKey_REF, TValue_REF>)
0x0000021308298acb (Mono JIT Code) System.Runtime.CompilerServices.ConditionalWeakTable`2<TKey_REF, TValue_REF>:GetOrCreateValue (TKey_REF)
0x00000213082b6863 (Mono JIT Code) [Memo.cs:15] YoutubeExplode.Utils.Memo/For`1<System.Nullable`1<int>>:GetCache (object)
0x00000213082b665b (Mono JIT Code) [Memo.cs:20] YoutubeExplode.Utils.Memo:Cache<System.Nullable`1<int>> (object,System.Func`1<System.Nullable`1<int>>)
0x00000213082bf16b (Mono JIT Code) [PlayerStreamInfoExtractor.cs:127] YoutubeExplode.Bridge.PlayerStreamInfoExtractor:TryGetFramerate ()
0x00000213082b5ba1 (Mono JIT Code) [StreamClient.cs:75] YoutubeExplode.Videos.Streams.StreamClient/<PopulateStreamInfosAsync>d__3:MoveNext ()
0x00000212e4dbca32 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)
0x00000212e1ab638e (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
0x00000212e1ab5acb (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
0x00000212e4dbc89b (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()
0x000002130828c8aa (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:InvokeAction (object)
0x00000212e6191155 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&)
0x00000212e6190fd3 (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)
0x00000212e1af1383 (Mono JIT Code) System.Threading.Tasks.Task:FinishContinuations ()
0x00000212e1af0803 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageThree ()
0x000002130832584b (Mono JIT Code) System.Threading.Tasks.Task`1<System.Nullable`1<long>>:TrySetResult (System.Nullable`1<long>)
0x0000021308325703 (Mono JIT Code) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<System.Nullable`1<long>>:SetResult (System.Nullable`1<long>)
0x00000213083255d3 (Mono JIT Code) System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1<System.Nullable`1<long>>:SetResult (System.Nullable`1<long>)
0x0000021308300553 (Mono JIT Code) [HttpExtensions.cs:59] YoutubeExplode.Utils.Extensions.HttpExtensions/<TryGetContentLengthAsync>d__2:MoveNext ()
0x00000212e4dbca32 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)
0x00000212e1ab638e (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
0x00000212e1ab5acb (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
0x00000212e4dbc89b (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()
0x000002130828c8aa (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:InvokeAction (object)
0x00000212e6191155 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&)
0x00000212e6190fd3 (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)
0x00000212e1af1383 (Mono JIT Code) System.Threading.Tasks.Task:FinishContinuations ()
0x00000212e1af0803 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageThree ()
0x00000212e4d75203 (Mono JIT Code) System.Threading.Tasks.Task`1<TResult_REF>:TrySetResult (TResult_REF)
0x00000212e4e13e43 (Mono JIT Code) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<TResult_REF>:SetResult (TResult_REF)
0x000002130828cd6b (Mono JIT Code) System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1<TResult_REF>:SetResult (TResult_REF)
0x0000021308300cab (Mono JIT Code) [HttpExtensions.cs:22] YoutubeExplode.Utils.Extensions.HttpExtensions/<HeadAsync>d__0:MoveNext ()
0x00000212e4dbca32 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)
0x00000212e1ab638e (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
0x00000212e1ab5acb (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
0x00000212e4dbc89b (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()
0x000002130827533a (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation/<>c:<.cctor>b__7_0 (object)
0x0000021308275274 (Mono JIT Code) UnityEngine.UnitySynchronizationContext/WorkRequest:Invoke ()
0x00000212e4d91d3b (Mono JIT Code) UnityEngine.UnitySynchronizationContext:Exec ()
0x00000212e4d9190b (Mono JIT Code) UnityEngine.UnitySynchronizationContext:ExecuteTasks ()
0x00000213b08409b5 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
0x00007ffd9717e0a4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
0x00007ffd970be744 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
0x00007ffd970be8dc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
0x00007ff62b342834 (Unity) scripting_method_invoke
0x00007ff62b33d454 (Unity) ScriptingInvocation::Invoke
0x00007ff62b336d75 (Unity) ScriptingInvocation::Invoke<void>
0x00007ff62b448b5b (Unity) Scripting::UnityEngine::UnitySynchronizationContextProxy::ExecuteTasks
0x00007ff62b01cb86 (Unity) `InitPlayerLoopCallbacks'::`2'::UpdateScriptRunDelayedTasksRegistrator::Forward
0x00007ff62b0036bc (Unity) ExecutePlayerLoop
0x00007ff62b003793 (Unity) ExecutePlayerLoop
0x00007ff62b0093d9 (Unity) PlayerLoop
0x00007ff62bf4cf84 (Unity) PlayerLoopController::UpdateScene
0x00007ff62bf4b1ff (Unity) Application::TickTimer
0x00007ff62c396b6a (Unity) MainMessageLoop
0x00007ff62c39b41b (Unity) WinMain
0x00007ff62d6cab6e (Unity) __scrt_common_main_seh
0x00007ffe02e07034 (KERNEL32) BaseThreadInitThunk
0x00007ffe03802651 (ntdll) RtlUserThreadStart
I don’t believe this is a Unity-specific issue, as it seems Unity claims the library itself is sending a SIGSEGV when it tries to cast a PlayerStreamInfoExtractor:TryGetFramerate, at least, that’s what I’m reading into this error.
Steps to reproduce
- Import YoutubeExplode.dll into Unity Project
- Call DownloadAsync, GetMuxedStream, and DownloadAsync. Really, just call the example code given in the Github README.
- Wait. It will happily go through a few videos, sometimes crash immediately, but always eventually crash.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (1 by maintainers)
@jakedowns Incredibly sorry for the late reply. I can confirm that the package seems to not work on 2022 or 2023, and Unity complains that the code should be “natively compiled” (see https://forum.unity.com/threads/solved-build-failed-il2cpp.1164539/).
It fully builds and works on Unity 2021.3.15f1 for me, and even testing with an .aab, I was able to upload to Google Play as well. Given that I had built on 3.3f1 previously, I would say it’s safe to assume that any 2021 version works.
After building, I was getting crashes on my device- and had to turn off any and all minification and “Stripping Code”, which I know you’ve spoken of before in your issue. As for the strange JSON text error, or other errors of that nature, it’s likely some cause of the .NET version your Unity is using or something along those lines. Everything else equal, something that compiles and deploys fine on my end should do the same on yours, lest our machines have different dependencies (i.e. .net versions).
Good luck.
Fixed. I ran it for a few hours and it didn’t crash.
The problem is more on Unity’s side than it is on yours. They have an option called “strip engine code” in their game settings, which helps to optimize game size, but it seems that it was also causing useful objects, like
ConditionalWeakTable
, to error out. This is an issue I’ll file with Unity, but the temporary fix is just to disable stripping engine code.To anyone that has the same issue -> Player Settings -> Strip Engine Code -> Disabled
Thanks for the awesome plugin, Tyrrrz.