Custom keyboard randomly crash with NSExtension Error

I'm currently developing a custom keyboard which bundled with main app.

The keyboard would randomly crash when switch between apps with opened custom keyboard on physical device.

I've read posts around but seems not what I've encountered.

Bundle ID of main app: com.company.appName

Bundle ID of keyboard extension: com.company.appName.Keyboard

When custom keyboard is opened second time on other app, a sole personality warning would show up, but this won't lead to crash.

WARNING! Sole personality is ambiguous; this may lead to erratic behavior

[lifecycle] [u 9A2D7B1D-20AF-4E2A-A72F-C37C8D4FDEEA] [com.company.appName.Keyboard(1.0.0)] WARNING! Sole personality is ambiguous; this may lead to erratic behavior; personalities: {
    "com.companyName.appName.keyboard" =     {

        19209 = "<PKServicePersonality: 0x28299da00; core = <[u 9A2D7B1D-20AF-4E2A-A72F-C37C8D4FDEEA] [com.company.appName.Keyboard(1.0.0)],[d (null)] [/private/var/containers/Bundle/Application/67892ACC-5BDA-4205-828D-4D94D6E87ABD/AppName.app/PlugIns/Keyboard.appex]>, host pid = 19209>";

        19293 = "<PKServicePersonality: 0x28298fb00; core = <[u DA59190E-D8A2-4109-8D7B-1702E03AB0BD] [com.company.appName.Keyboard(1.0.0)],[d (null)] [/private/var/containers/Bundle/Application/67892ACC-5BDA-4205-828D-4D94D6E87ABD/AppName.app/PlugIns/Keyboard.appex]>, host pid = 19293>";

        299 = "<PKServicePersonality: 0x282981700; core = <[u 61DC0533-3D02-4CE7-83C2-D698537BC6ED] [com.company.appName.Keyboard(1.0.0)],[d (null)] [/private/var/containers/Bundle/Application/67892ACC-5BDA-4205-828D-4D94D6E87ABD/AppName.app/PlugIns/Keyboard.appex]>, host pid = 299>";
    };
}

After switching between apps for few times, the custom keyboard would crash, common crash log is :

Connection to plugin invalidated while in use.

2023-12-13 10:19:44.220973+0800 MobileNotes[36435:1892265] [lifecycle] [u 9A37D3B6-CAE5-4E5C-95FF-DA653DC080E5:m (null)] [com.companyName.appName.Keyboard(1.0.0)] Connection to plugin interrupted while in use.

2023-12-13 10:19:44.221229+0800 MobileNotes[36435:1892265] [lifecycle] [u 9A37D3B6-CAE5-4E5C-95FF-DA653DC080E5:m (null)] [com.companyName.appName.Keyboard(1.0.0)] Connection to plugin invalidated while in use.

Another crash log is bit more detailed, but still not sure what it may refers to.

`
2023-12-13 10:19:44.222563+0800 MobileNotes[36435:1892256] [NSExtension] Unable to setup extension context - error: Couldn’t communicate with a helper application.

2023-12-13 10:19:44.222646+0800 MobileNotes[36435:1892256] [NSExtension] Async Begin using internal completion handler called multiple times. Due to error after initial completion: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.company.appName.Keyboard.apple-extension-service" UserInfo={NSDebugDescription=connection to service named com.company.appName.Keyboard-extension-service}
Program ended with exit code: 9`