WebGL-Inspector icon indicating copy to clipboard operation
WebGL-Inspector copied to clipboard

Race condition in embed.js?

Open cscheid opened this issue 11 years ago • 1 comments

I think there's a race condition in embed.js.

What happens is that embed.js calls insertScript to get all the gli code in, but that code is not synchronous.

Later on, embed.js monkey-patches the HTMLCanvasElement prototype's getContext and introduces a reference to the gli variable.

If someone decides to create a context before gli.all.js has loaded, the gli resolves to null, and the block in lines 116--119 will always throw exceptions. No contexts ever created! :(

There doesn't seem to be a simple way to solve this besides. Perhaps getContext should throw a special "come back later" exception?

Fundamentally, it's not enough to assume that embed.js was included before anything else, because script tag insertion is async.

cscheid avatar Sep 30 '14 00:09 cscheid

Yep. I also notice this problem. This happens frequently while embed debugging mode.

daoshengmu avatar Dec 30 '15 16:12 daoshengmu