Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in embed.js? #126

Open
cscheid opened this issue Sep 30, 2014 · 1 comment
Open

Race condition in embed.js? #126

cscheid opened this issue Sep 30, 2014 · 1 comment

Comments

@cscheid
Copy link

cscheid commented Sep 30, 2014

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.

@daoshengmu
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants