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 can cause JS to reference nonexistent elements #102

Open
speezepearson opened this issue Jun 27, 2017 · 0 comments
Open

Race condition can cause JS to reference nonexistent elements #102

speezepearson opened this issue Jun 27, 2017 · 0 comments
Labels

Comments

@speezepearson
Copy link
Owner

speezepearson commented Jun 27, 2017

Consider this code:

import time
from browsergui import Button, GUI
b = Button()
@b.def_callback
def _():
  b.text = "Clicked"
  gui.body.remove(b)
  # browser requests command
  gui.body.append(b)

gui = GUI(b)
gui.run()

If the browser requests a lump of JS at the marked point in the code, the generated JS can look like "wipe out everything in the document body; then get the button element and..."; but the button element no longer exists, so executing the JS raises an error in the browser, which ends up closing the browser window. (This won't always happen, because the order of the JS commands is nondeterministic.)

I think DocumentChangeTracker needs a serious refactor. It's always felt a little wonky to me, and the fact that this kind of error is possible (even though I tried to threadsafe it) suggests something is horribly wrong with the architecture.

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

No branches or pull requests

1 participant