# 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:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![JK1](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@JK1](https://community.nianticspatial.com/u/JK1)
#### Post date: [September 24, 2025, 11:55pm UTC](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527/21 "2025-09-24T23:55:37Z")

</div>

Thanks. I wish you guys fix MeshingModule issue that the meshesChanged doesn’t get invoked. There seems ARMeshManager keeps updating the mesh but ARDK MeshingModule doesn’t update vertices in second load. Maybe some sort of reset interface is needed in ARDK side I guess.

Until then, I’ll stick with my workaround.

Thanks

– JK

---

<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")

```

* * *

---

<div class="post-metadata">

### Author: ![STak4](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/stak4/32/2481_2.png) [@STak4](https://community.nianticspatial.com/u/STak4)
#### Post date: [November 24, 2025, 6:40am UTC](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527/23 "2025-11-24T06:40:35Z")

</div>

Thank you all. These solutions work in my app.

I added minor changes. no need to change `LightshipARDK.m`

1.Disable registration on applicationDidFinishLaunching and add loading function.  
`RegisterPlugin.mm`

```auto
...
#import "IUnityInterface.h"

// $EDIT: add function for load plugin from Unity
#ifdef __cplusplus
extern "C" {
#endif
void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API LightshipARDK_LoadPluginFromUnity()
{
    NSLog(@"LightshipARDK_LoadPluginFromUnity");
    UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}
#ifdef __cplusplus
} // extern "C"
#endif
...
-(void)applicationDidFinishLaunching:(NSNotification*) notification
{
    NSLog(@"[Override_iOS applicationDidFinishLaunching:%@]", notification);
    // $EDIT: for manual load plugin from Unity
    // UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}

```

2.Call `LightshipARDK_LoadPluginFromUnity` from Unity.  
`LightshipUnityContext.cs`

```auto
...
    public class LightshipUnityContext
    {
# if UNITY_IOS && !UNITY_EDITOR
        /// <summary>
        /// $EDIT: Manual load plugin by added function
        /// https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527/22
        /// </summary>
        /// <returns></returns>
        [DllImport("__Internal", EntryPoint = "LightshipARDK_LoadPluginFromUnity")]
        public static extern void LoadPluginFromUnity();
#endif
...
        internal static void Initialize(bool isDeviceLidarSupported, bool disableTelemetry = false, string featureFlagFilePath = "")
        {
#if NIANTIC_LIGHTSHIP_AR_LOADER_ENABLED
# if UNITY_IOS && !UNITY_EDITOR
            // $EDIT: load plugin on initialize
            Debug.Log("LoadPluginFromUnity start");
            LoadPluginFromUnity();
            Debug.Log("LoadPluginFromUnity end");
#endif

```

---

<div class="post-metadata">

### Author: ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)
#### Post date: [March 5, 2026, 11:10pm UTC](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527/24 "2026-03-05T23:10:05Z")

</div>



[Previous page](https://community.nianticspatial.com/t/ardk3-crashes-app-with-failed-to-load-plugin-plugin-loading-is-only-allowed-on-main-thread/5527.md?page=1)
