Repository: godot
Issue: [4.2] [.net] iOS crash: mutex lock failed during RenderingServerDefault::_draw
Labels: bug,platform:ios,topic:dotnet,topic:export

Edit: see notes in my comment below for the root cause analysis

### Tested versions

Godot 4.2 is the first version I was able to export to iOS, so I am unable to confirm whether this problem exists in prior versions.

### System information

Running on ios 16.6. Built from Godot v4.2.stable.mono - macOS 14.1.1 - Vulkan (Mobile) - integrated Apple M1 Max - Apple M1 Max (10 Threads)

### Issue description

When exporting and running my game on iOS, the game is consistently crashing with the following stack trace. 

To be honest, I am having a difficult time resolving the conditions under which this happens. From my testing it seems to happen when running several tweens in a recently loaded scene. It is inconsistent enough to make me think it's related to a race condition somewhere.

```
libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00000001efd95578 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000210c10118 libsystem_pthread.dylib`pthread_kill + 268
    frame #2: 0x00000001b8300178 libsystem_c.dylib`abort + 180
    frame #3: 0x0000000210b4ebf8 libc++abi.dylib`abort_message + 132
    frame #4: 0x0000000210b3e428 libc++abi.dylib`demangling_terminate_handler() + 320
    frame #5: 0x00000001a9e7deb4 libobjc.A.dylib`_objc_terminate() + 160
    frame #6: 0x0000000210b4dfbc libc++abi.dylib`std::__terminate(void (*)()) + 16
    frame #7: 0x0000000210b50d34 libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
    frame #8: 0x0000000210b50ce0 libc++abi.dylib`__cxa_throw + 140
    frame #9: 0x00000001bf4368bc libc++.1.dylib`std::__1::__throw_system_error(int, char const*) + 100
    frame #10: 0x00000001bf42af90 libc++.1.dylib`std::__1::mutex::lock() + 40
    frame #11: 0x00000001bf42eda4 libc++.1.dylib`std::__1::__shared_mutex_base::unlock_shared() + 24
    frame #12: 0x0000000104c644e8 ios`Object::emit_signalp(StringName const&, Variant const**, int) + 504
    frame #13: 0x00000001041d0570 ios`RenderingServerDefault::_draw(bool, double) + 120
    frame #14: 0x00000001024895b8 ios`Main::iteration() + 1176
    frame #15: 0x000000010246ba40 ios`-[GodotView drawView] + 520
    frame #16: 0x00000001b231c328 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 820
    frame #17: 0x00000001b232c2d0 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 372
    frame #18: 0x00000001b0e48d54 CoreFoundation`__CFMachPortPerform + 176
    frame #19: 0x00000001b0e66148 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    frame #20: 0x00000001b0e67e38 CoreFoundation`__CFRunLoopDoSource1 + 520
    frame #21: 0x00000001b0e49658 CoreFoundation`__CFRunLoopRun + 2240
    frame #22: 0x00000001b0e4e3ec CoreFoundation`CFRunLoopRunSpecific + 612
    frame #23: 0x00000001ec36435c GraphicsServices`GSEventRunModal + 164
    frame #24: 0x00000001b31daf58 UIKitCore`-[UIApplication _run] + 888
    frame #25: 0x00000001b31dabbc UIKitCore`UIApplicationMain + 340
    frame #26: 0x00000001024605ec ios`main + 128
    frame #27: 0x00000001d0380dec dyld`start + 2220
```

### Steps to reproduce

Unfortunately I don't know how to recreate this bug from a new project. The stack trace is ambiguous enough that I cannot correlate it to anything I am doing in my game code.

### Minimal reproduction project (MRP)

(see above)