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

Zoom-in/out/home/fullscreen buttons' image loading is failing sporadically, when running on Flask server (or any slow server) #2525

Open
szabonandi opened this issue May 2, 2024 · 4 comments

Comments

@szabonandi
Copy link

I observed that running openseadragon on python Flask server has an issue, when the initial load of the navigating button happens.
The GET requests toward the server are sent parallel apparently, and sometimes the server is not able to respond them.
Which results in displaying the alternate text, instead of the proper image button.

I added a workaround, to delay the fetch of the image buttons as follows:

        makeTransparentImage: function(e) {
            var t = u.makeNeutralElement("img");

            // add this extra while loop for 20msec syncrhonous delay:
            let datetime1 = new Date().getTime();
            let datetime2 = datetime1 + 20;
            while (datetime1 < datetime2) {
                datetime1 = new Date().getTime();
            }
            // delay finished, continue with image fetch:

            t.src = e;
            return t
        },

This workaround helped, and the server was able to answer properly the requests arriving in a more paced way.

To handle the issue, I propose some new viewer option (similar to the existing "imageLoaderLimit"), which can configure the delay between the button image loading requests, in case of slow servers.

@iangilman
Copy link
Member

Does your server also have trouble serving the image tiles in time? Or is that fine because they are loaded one at a time?

This is the first I've heard of this issue, so I don't know how widely-used such a feature would be. If you want to pursue adding it, though, I can help point you in the right direction. If nothing else, this issue report can be helpful to others who encounter the same problem; thank you for reporting it!

@szabonandi
Copy link
Author

Hi iangilman.
Yes, i had issues with the tile loading as well, until i set the "imageLoaderLimit" option to value 1.
But it is only affects the tile loading.
To fix the button image loading issue also, i had to introduce the workaround with the 20msec deley.

@szabonandi
Copy link
Author

To solve the issue caused by the slow python Flask web server, I introduced a NGINX proxy in front of the python Flask server.
This NGINX proxy is configured to serve the static content (tiles, openseadragon artifact, eg. button images, script etc.), and everything else which is dynamic content is proxied to the python Flask server.
As NGINX has good performance in serving static content, the Flask server load decreased a lot, it only serves the absolute neccesary.
This hybrid setup works fine.

Going back to the original topic:
Despite that the problem is solved by a workaround, but:
for such situations, where this traffic offloading from the low performance server is not an option, the configurable concurrency and/or time pacing would be still a useful feature in openseadragon.

@iangilman
Copy link
Member

Great... Sounds like a good setup. Thank you for sharing the info on it.

And yes, we'll leave this issue open in case someone wants to tackle adding the feature.

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

2 participants