WebGL Issue in unity :ConvaiClient is not defined

Hello,
I’m currently trying to use the Convai SDK with a WebGL Unity build, but I’m encountering a critical error in the browser console:
Uncaught ReferenceError: ConvaiClient is not defined.

It seems like the WebGL build is expecting a JavaScript module or interop function that isn’t available. Could you please confirm whether the Convai SDK officially supports WebGL, and if so, what additional setup (e.g., JS libraries or manual scripts) is required to make it work properly?

Thank you in advance for your help.

Hello @ssh87926,

Welcome to the Convai Developer Forum!

Could you please share a screenshot of your scene hierarchy?

@K3

Update: My issues has been resolved actually. I just had to remove another scene that I had in the “Scenes in build”

Hello, I’m facing the same error. Whenever I send text to the AI NPC, the game lags and I get the same error in then console:

Uncaught ReferenceError: ConvaiClient is not defined

An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.

I have followed this tutorial (Building for WebGL), and I’m only building the demo convai scene without any changes. I’m using Unity 2022.3.11f1, and developing/building from a Mac.

@K3

Actually, today I’m running into the same issue again, despite having my demo convai scene as the only one in “Scenes in build”. I tested multiple wifi networks, and my issue persists. I get the same errors as before:

[Warning][Character]: [ConvaiGRPCWebAPI] UpdateActionConfig called, but no active NPC.
Uncaught ReferenceError: ConvaiClient is not defined
An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.

Could you please share a screenshot of your scene hierarchy?

Here it is. Let me know if you’d like me to expand it further.

Thank you in advance!

Did you make any changes to the scripts or modify the gameobjects in the scene?

Yes, I tried to add a custom character to the scene, then it broke. Then I went back to my previous working commit (with the unchanged demo scene) and it didn’t work as well.

I did some further testing, and now Convai works fine even with the custom character on localhost when I “Build and run”. But when I publish the game, Convai doesn’t work even on the basic characters, and I get the errors I mentioned above.

[Warning][Character]: [ConvaiGRPCWebAPI] UpdateActionConfig called, but no active NPC.
Uncaught ReferenceError: ConvaiClient is not defined
An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.

Please share the all logs.

I’ve attached it below. Also, here’s the published game for reference.

play.unity.com-1754812529773.log (906.5 KB)

Which WebGL template do you use?

And could you please enable Full With Stacktrace so we can see the details.

I’m using Convai_Unity_WebGL_SDK_v3.0.0

May I also ask, how do I enable Full With Stacktrace for my published build? I’ve only found instructions on how to do it for the local build (which isn’t facing any issues at the moment).

Thank you! I enabled Full With Stacktrace. Here’s the log and published game.

play.unity.com-1754822625803.log (908.3 KB)

Which WebGL Template do you use?

Convai PWA template. I followed this tutorial.

How do you deploy to this page?

In Unity, I go to Publish >> WebGL Project >> Create and Publish new.

I’ve also tried Build Setting >> Build and Run. Then Publish >> WebGL Project >> Publish (on my selected build).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.