# ARDK3: Crashes App with "Failed to load plugin. Plugin loading is only allowed on main thread."

**URL:** https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527
**Category:** Bug Reports
**Created:** [August 4, 2025, 3:21am UTC](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527 "2025-08-04T03:21:43Z")
**Posts on this page:** 1
**Showing post:** 22

<div class="post-metadata">

### Author: ![Kei\_Hasegawa](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@Kei\_Hasegawa](https://community.nianticspatial.com/u/Kei_Hasegawa)
#### Post date: [November 11, 2025, 3:44am UTC](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527/22 "2025-11-11T03:44:46Z")

</div>

In my app, the following workaround seems to work with UaaL on iOS devices.  
Please note that I don’t fully understand all the details, so use this at your own risk.

1. Disable plugin registration in `RegisterPlugin.mm`

```objc
// Runtime/Plugins/iOS/RegisterPlugin.mm
-(void)applicationDidFinishLaunching:(NSNotification*) notification
{
    NSLog(@"[Override_iOS applicationDidFinishLaunching:%@]", notification);
    // Do not register here.
    // UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}
@end

```

2. Add plugin loading function to `LightshipARDK.m` called from Unity.

```objc
// Runtime/Plugins/iOS/LightshipARDK.m
void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API LightshipARDK_LoadPluginFromUnity()
{
    NSLog(@"LightshipARDK_LoadPluginFromUnity");
    UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}

@interface LightshipARDK : NSObject

+ (void)loadPlugin;
...

```

3. Call `LightshipARDK_LoadPluginFromUnity` from Unity

Add `LoadPluginFromUnity`

```csharp
// Runtime/Core/LightshipUnityContext.cs
public class LightshipUnityContext
{
    [DllImport("__Internal", EntryPoint = "LightshipARDK_LoadPluginFromUnity")]
    public static extern void LoadPluginFromUnity();

```

and call it from `Initialize` method.

```csharp
    internal static void Initialize(bool isDeviceLidarSupported, bool disableTelemetry = false, string featureFlagFilePath = "")
    {
#if NIANTIC_LIGHTSHIP_AR_LOADER_ENABLED
        // load plugin on initialize
        Debug.Log("LoadPluginFromUnity start")
        LoadPluginFromUnity();
        Debug.Log("LoadPluginFromUnity end")

```

* * *

---

_[View the full topic](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527)._
