nschloe / tuna

:fish: Python profile viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IPython magics broken in tuna >=5.0

asford opened this issue Β· comments

First, πŸ‘ πŸ‘ πŸ‘ , this is an amazingly useful profiling tool. Thanks!

The ipython magics are broken in release 5.0+ with the browser console traceback of:

Uncaught TypeError: Cannot read property 'addEventListener' of null
    at HTMLElement.render (about:srcdoc:132)
    at HTMLElement.connectedCallback (about:srcdoc:112)
    at about:srcdoc:270

This is being raised after failing to resolve the "resetZoomButton" added in #87 at https://github.com/nschloe/tuna/blob/v0.5.3/tuna/web/static/icicle.js#L27-L30

It's not entirely clear to me why the strategy used in the magics doesn't work here, but I believe it may be because an object is specified by ID in the tuna javascript but then isn't present in the IFrame generated by the magic?

I've uploaded a full repro to nbviewer:
https://nbviewer.jupyter.org/gist/asford/35eebdaba46cb3e513565d6fc8440763

It should be possible to open this viewer to view the error traceback in the browser developer console.

No idea why this should be happening, really. I'll be more than happy to review PRs fixing this!

This happens because the reset zoom button is in a nav element, but I remove nav elements from the html in the IPython magic (I found it nicer without the nav bar when it's already embedding in a notebook). Then from icicle.js, it tries to access the button, but there's nothing to find.

It's easy to remove just the nav bar and leave the reset zoom button or even leave the button and the nav bar, but when I tested using the reset zoom button in a notebook, I just get a few hundred errors in the console like Error: <rect> attribute y: Expected length, "NaN". I don't mind the lack of this button right now, so I probably won't debug why it doesn't work in a jupyter notebook.

In my local version, my "fix" is to just keep the reset zoom button removed and also remove the reference to it from icicle.js (only when in-lining icicle.js into the HTML to put in the notebook; I don't edit the actual .js file). I could submit a PR for this if desired, since it's probably nicer to have the notebook version working without a reset zoom button rather than not working at all. If you want to hold out for a real fix that makes the button work, though, that's fine.