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

JupyterWidgetView rendered twice on initialization #20

Open
dorisjlee opened this issue Jul 20, 2020 · 1 comment
Open

JupyterWidgetView rendered twice on initialization #20

dorisjlee opened this issue Jul 20, 2020 · 1 comment
Labels
bug Something isn't working hard issues that are non-trivial and hard to support

Comments

@dorisjlee
Copy link
Member

This is traced back to internal calls in backbone.js and extension.js for create_view (which is called twice), leading the JupyterWidgetView class to be initialized twice.

export class JupyterWidgetView extends DOMWidgetView {

  initialize(){    
        ....
       ReactDOM.render(App,$app);
       view.el.append($app);
  }

It is unclear if this is an issue with the ipywidget internal or something different we have to do in our JupyterWidgetView react class (perhaps wrapping it in something other than initialize?).

Action Items:
For now, the logger accounts for this by de-duplicating initWidget events that occur together in too short a timespan.
We should look into this issue closer since this may cause a slowdown as the widget frontend needs to render two times.

@dorisjlee dorisjlee added bug Something isn't working hard issues that are non-trivial and hard to support labels Jul 20, 2020
@jakeatgalileo
Copy link
Contributor

jakeatgalileo commented Nov 9, 2020

It seems as though this issue is in the backend as you can see the widget get rendered twice in the console (pressing f12) and seeing that the widget objects in both render attempts are the same. However, there is still a possibility the problem is in the frontend from the way we initialize our widget.

In the backend, in (https://github.com/lux-org/lux/blob/master/lux/core/frame.py), if you get rid of self.output, in on_button_clicked, and display the widget directly onto whatever the output area of repr_html is, the widget actually renders once. The caveat is that since you are displaying directly to the output area of repr_html, you cannot access this area outside of repr_html. Or I couldn't find a way to refresh the widget in the backend when setting intent from the frontend. I'm not exactly sure why this is the behavior but the answer may lie in the internals of the output widget and its interactions with repr_html?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hard issues that are non-trivial and hard to support
Projects
None yet
Development

No branches or pull requests

2 participants