Skip to content

Conversation

@alexhuth
Copy link
Contributor

In somewhat related things, there's an annoying Heisen-bug in how the tornado websocket communication works. If it tries to send too many queries too quickly, tornado just barfs. This fix is based on: tornadoweb/tornado#2871

I believe this fix works well — I haven't been able to replicate the problem since applying this fix — but the problem was random before, so I'm not 100% certain.

I also believe that this fix should make a lot of time.sleep calls unnecessary (removing them seemed to have no effect), but, again, the effect of those pauses is inconsistent.

@TomDLT
Copy link
Contributor

TomDLT commented Apr 27, 2022

Looks reasonable, although I have not been able to replicate the issue the sleeps are fixing.
I will try with another machine tomorrow.

Looks like all these lines could be removed, and other sleeps in cortex.webgl.view.py might be removed too.
This sleep cannot be removed though.

@mvdoc
Copy link
Contributor

mvdoc commented Apr 30, 2022

I tested this change on my aging macbook air, and it works fine.

Re the sleeps: I was hoping they would be helpful in solving the (random) webgl crashes I would get from time to time (see the trace below—I'm not 100% sure, but it seems like webgl is taking too long to set the new attributes?).

$ python multi_panels_plots.py
Started server on port 3266
{'camera.azimuth': 0, 'camera.altitude': 90, 'camera.target': [0, 0, 0], 'surface.{subject}.unfold': 0.5, 'surface.{subject}.pivot': 180, 'surface.{subject}.shift': 10, 'surface.{subject}.specularity': 0, 'surface.{subject}.sampler': 'nearest', 'surface.{subject}.layers': 1}
{'camera.azimuth': 180, 'camera.altitude': 90, 'camera.target': [0, 0, 0], 'surface.{subject}.unfold': 0.5, 'surface.{subject}.pivot': 180, 'surface.{subject}.shift': 10, 'surface.{subject}.specularity': 0, 'surface.{subject}.sampler': 'nearest', 'surface.{subject}.layers': 1}
Traceback (most recent call last):
  File "multi_panels_plots.py", line 42, in <module>
    cortex.export.plot_panels(volume, **params)
  File "/Users/mvdoc/Documents/repos/pycortex/cortex/export/panels.py", line 108, in plot_panels
    layers=layers,
  File "/Users/mvdoc/Documents/repos/pycortex/cortex/export/save_views.py", line 114, in save_3d_views
    handle._set_view(**this_view_params)
  File "/Users/mvdoc/Documents/repos/pycortex/cortex/webgl/view.py", line 488, in _set_view
    subject_list = self.ui.surface._folders.attrs.keys()
  File "/Users/mvdoc/Documents/repos/pycortex/cortex/webgl/serve.py", line 328, in __getattr__
    assert attr in self.attrs
AssertionError

@alexhuth
Copy link
Contributor Author

alexhuth commented May 1, 2022

@mvdoc that's very closely related to the problem this branch is fixing, which was also intermittent and related to those javascript-derived variables being filled with values via the websocket. Have you tried replicating that with webgl-racecondition-fix?

@mvdoc
Copy link
Contributor

mvdoc commented May 1, 2022

Yes, I still hit the same issue (randomly) with the webgl-racecondition-fix branch. (The error I pasted actually comes from the first time I tested the branch.)

Copy link
Contributor

@mvdoc mvdoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR can be merged. It didn't solve the issue I often hit, but the change in the code seems reasonable (writing with async). I would maybe keep the sleeps in there just as a safety measure.

@mvdoc mvdoc merged commit 1ae5f25 into main May 16, 2022
@mvdoc mvdoc deleted the webgl-racecondition-fix branch May 16, 2022 18:36
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

Successfully merging this pull request may close these issues.

4 participants