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

Embedding NGL 2.2.2 (via nglview) doesn't work anymore #1014

Open
hainm opened this issue Jan 17, 2024 · 9 comments
Open

Embedding NGL 2.2.2 (via nglview) doesn't work anymore #1014

hainm opened this issue Jan 17, 2024 · 9 comments
Assignees
Labels

Comments

@hainm
Copy link
Contributor

hainm commented Jan 17, 2024

It's hard to describe this issue but I will try my best.

Basically nglview uses this chunk of codes to generate the embeddable HTML: https://github.com/nglviewer/nglview/blob/98d7df9c5b2c035278724eacfb8184631c17015b/js/webpack.config.js#L48-L73

Something like below (in juypter notebook):

# 1st cell
import nglview as nv
view = nv.demo()
view

# 2nd cell
nv.write_html("index.html", view)
!open index.html

Upgrading from NGL 2.0.0-dev.39 to 2.2.2 make the embedding stop working. Below is the error:

image

I originally thought it was an issue with ipywidgets (jupyter-widgets/ipywidgets#3878), but I've tried to switch back to NGL 2.0.0-dev.39 with the same ipywidgets version and thing still works properly.

Can you please have a look.
Thanks

Hai

@hainm
Copy link
Contributor Author

hainm commented Jan 17, 2024

Oh, NGL 2.2.2 works fine with the jupyter notebook and lab (via nglview). It's just the HTML exporting doesn't work.

@hainm
Copy link
Contributor Author

hainm commented Jan 17, 2024

The latest "working" version is 2.1.1

image

@papillot
Copy link
Contributor

@hainm a view of the line that fails within the source code would be very useful, or a way to reproduce it (a live version somewhere?)
Between 2.1.1 and 2.2.0 the bundling has changed. It's possible that's the cause of this bug

@hainm
Copy link
Contributor Author

hainm commented Jan 19, 2024

@hainm a view of the line that fails within the source code would be very useful, or a way to reproduce it (a live version somewhere?) Between 2.1.1 and 2.2.0 the bundling has changed. It's possible that's the cause of this bug

Dear @papillot

Please download (and rename) this file: https://github.com/jupyter-widgets/ipywidgets/files/13894919/index.html.txt

@ppillot
Copy link
Collaborator

ppillot commented Jan 27, 2024

Thanks for this. I did a first pass at investigating this last week. This is related to a change in the bundling system. The esm module that is loaded in this case, contains mangled names for Three.js dependency constants.
Mangling is fine when Three.js is part of the bundle (that is the case with the "regular" .min.js bundle). I am not sure it makes sense in the case of esm.

@ppillot ppillot added the bug label Jan 27, 2024
@hainm
Copy link
Contributor Author

hainm commented Mar 4, 2024

Dear @ppillot,

do you have a solution yet? If not, is it possible to follow the old way that works?

@papillot
Copy link
Contributor

papillot commented Mar 4, 2024

For various reasons, I haven't made any progress on this. I did investigate further and noticed that the previous code also had mangled identifiers.

@hainm
Copy link
Contributor Author

hainm commented Mar 4, 2024

thanks for the update.

@hainm
Copy link
Contributor Author

hainm commented Jul 16, 2024

It seems to me that upgrading to latest NGL (in this thread) will prevent nglview from being displayed in VSCode too:
microsoft/vscode-jupyter#15757 (comment)

User reported that nglview 3.0.8 works fine but the subsequent versions do not work. We introduce new NGL after 3.0.8
image

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

4 participants