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

Improve the WebGL backend #607

Closed
4 of 10 tasks
rossant opened this issue Oct 30, 2014 · 12 comments
Closed
4 of 10 tasks

Improve the WebGL backend #607

rossant opened this issue Oct 30, 2014 · 12 comments

Comments

@rossant
Copy link
Member

rossant commented Oct 30, 2014

This is a list of things to do to improve the WebGL backend once PR #592 is merged.

JavaScript loading

  • Refactor vispy.js to use browserify instead of requireJS.
  • Do not install nbextension if not necessary. The required JS files (notably vispy.min.js) are copied into the IPython profile everytime the ipynb_webgl backend is used. We could do a simple check to only copy if necessary (unless IPython's install_nbextension already does that).
  • Fail gracefully if WebGL is not available (and suggest the user to use the VNC backend)

vispy.js

  • Improve the GLIR implementation, notably:
    • in SHADERS, after attaching shaders, we should detach and destroy them
    • in TEXTURE, we should use the texture_number from the existing stored texture
    • try more complicated examples, notably with multiple textures
  • Implement framebuffers in vispy.js (they are not supported currently).

Misc

  • Solve issue Using initialize with gloo #606 so that all examples work in the notebook tackle issue Implement a server-side GLIR cache #615.
  • Use binary WebSockets (implemented in IPython master and upcoming IPython 3.0) to transfer NumPy arrays from Python to JavaScript.
  • Refactor ipynb_webgl so that other notebook backends can reuse most of the code (and bring back static and vnc).
  • Rename paint into draw
  • Implement VispyWidget(DOMWidget) (see comment below)
@mfkaptan
Copy link
Member

mfkaptan commented Dec 2, 2014

Do not install nbextension if not necessary. The required JS files (notably vispy.min.js) are copied into the IPython profile everytime the ipynb_webgl backend is used. We could do a simple check to only copy if necessary (unless IPython's install_nbextension already does that).

I think install_nbextension already does that:
"By default, this compares modification time, and only stages files that need updating. If overwrite is specified, matching files are purged before proceeding."
There is also check_nbextension, which checks whether nbextension files have been installed. Do you think this should be used?

@rossant
Copy link
Member Author

rossant commented Dec 2, 2014

Hi @mfkaptan!
Yes we could use something like that. I might be wrong but it seemed to me that it wasn't updating all the time. Maybe we could have a force option in vispy.use_app('ipynb_***') that would force the reinstallation of the nbextension. That's useful for debugging. Or, if we had a general DEBUG option, it could always reinstall the nbextension in that case. @Eric89GXL WDYT?

@larsoner
Copy link
Member

larsoner commented Dec 2, 2014

Could we add a function like vispy.app.backends.update_nbext() or so? Would that get you the debugging capabilities you want? We could also easily add a wrapper to make so you could do python make update_nbext from the vispy repo root.

mfkaptan added a commit to mfkaptan/vispy that referenced this issue Dec 17, 2014
Add force option (default false) to `_prepare_js()` in `_ipynb_webgl`.
If force is `true`, overwrite current files when installing nbextensions.
If force is `false`, use `check_nbextension()` first to see whether if it is necessary to install.
This commit is about issue vispy#607.
@mfkaptan
Copy link
Member

I have added force option as _prepare_js(force=False) to ipynb_webgl backend. I think the second part is to decide 'where should we get this option?' IMHO adding it as vispy.use_app('ipynnb_*, force=False') seems reasonable.

@rossant
Copy link
Member Author

rossant commented Dec 31, 2014

@mfkaptan I haven't tested it yet but that looks good to me.

@rossant
Copy link
Member Author

rossant commented Jan 3, 2015

Note to self:

I would like to make the following possible. I create a VisPy SceneCanvas as usual (e.g. a line plot). Next, I want to easily create an IPython DOMWidget that:

  • exposes several trait attributes, for example line_color
  • displays the SceneCanvas using WebGL in a cell's widget area

Here is how it could work:

Simple use

When there is no need to create a custom IPython widget.

import vispy
vispy.app.use_app('ipynb_webgl')

# create the SceneCanvas
canvas = ...

canvas.show()

Advanced use

import vispy
from vispy import VispyWidget
from IPython.display import display

# create the SceneCanvas
canvas = ...

class MyWidget(VispyWidget):
    """This class makes the bridge between the VisPy canvas and the WebGL widget.
    It exposes several trait attributes which notification callbacks can be customized.

    A VispyWidget is instanciated with a Canvas instance. Displaying the widget shows the
    WebGL version of the canvas.

    VispyWidget derives from IPython's DOMWidget.
    """

    # This trait attribute represent the line's color.
    line_color = 'blue'

    def on_trait_change(self, name, old, new):
        if name == 'line_color':
            self.canvas.myvisual.color = new

display(MyWidget(canvas))

@campagnola
Copy link
Member

Isn't this already possible just by implementing properties on the subclass, like

@line_color.setter
def line_color(self, color):
    self.myvisual.color = color

?

@rossant
Copy link
Member Author

rossant commented Jan 3, 2015

Not exactly it really needs to be a trait attribute so that it works with IPython's MVC system.

@larsoner larsoner added this to the version 0.5 milestone May 28, 2015
@dragoljub
Copy link

This looks very exciting. Thanks and keep up the great work. 😄

@larsoner
Copy link
Member

larsoner commented Jun 1, 2015

@dragoljub I think it's only supported on IPython version 3+, but that can be running Python 2.7 or 3.4 under the hood.

@dragoljub
Copy link

Yup I got it working after I updated to 4.0.

Thanks.

On Jun 1, 2015, at 7:00 AM, Eric Larson notifications@github.com wrote:

@dragoljub I think it's only supported on IPython version 3+, but that can be running Python 2.7 or 3.4 under the hood.


Reply to this email directly or view it on GitHub.

@larsoner larsoner removed this from the 0.5 milestone May 19, 2016
@djhoese
Copy link
Member

djhoese commented Aug 24, 2020

I think besides possibly the "fail gracefully" task, I think I finished all of these tasks in the 0.6 release. I still consider the jupyter widget experimental (performance is not great), but it "works".

@djhoese djhoese closed this as completed Aug 24, 2020
@djhoese djhoese self-assigned this Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants