jpauwels / pywebaudioplayer

https://pypi.org/project/pywebaudioplayer/
MIT License
10 stars 1 forks source link

Trackswitch Caching Problems #2

Closed sebastianrosenzweig closed 4 years ago

sebastianrosenzweig commented 4 years ago

Hi Johan, Thanks for your great work! It is really nice to have trackswitch.js in Jupyter notebooks!

In your examples notebook, I noticed the following issue: When running it for the first time, everything worked as expected. After I change the figure size of the last example spectrogram, e.g., to figsize=(10,2), the trackswitch player does not load anymore, only the figure is displayed. Furthermore, it seems that the figure size is not updated - it is still the original figure...

For me, it seems to be a caching problem (I am using Firefox...). One has to somehow force the browser to update the image. What do you think? Can you reproduce this issue?

Best regards, Sebastian

sebastianrosenzweig commented 4 years ago

When I clean the browser cache and offline website data between modifying the figure size and re-executing the last cell, the figure loads in the correct shape. However, the trackswitch player is still not visible...

sebastianrosenzweig commented 4 years ago

This solves the caching problem: https://stackoverflow.com/a/43640705 The trick is to append the figure file path (seekable_image_path) with ?<a random number>, which forces the browser to cache the files in a different way each time the function is called.

However, this is just a hack... can you think of an alternative? Or should we include this as a solution?

jpauwels commented 4 years ago

Hi Sebastian, thanks for your interest. The Jupyter Notebook integration is indeed still buggy, and one of the issues is that the errors are hard to reproduce consistently. I'm aware of some issues with reloading cells and it looks like you found a workaround for at least one of them. Thanks!

I'm still debating whether I should make a different submodule for Notebook integration, which might be necessary for fixing other bugs, or can keep a single codebase. I've got some improvements to wavesurfer ready for testing as well, but it won't be before the Christmas break before I can finish testing. I'll already accept your workaround for now, we can always improve on it later.