mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.

Home Page:https://pannellum.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent 'panorama is too big'

barryhunter opened this issue · comments

Have some relatively large panoramas, trying to get to display in pannellum. This is an example
https://cdn.pannellum.org/2.5/pannellum.htm#panorama=https://s1.geograph.org.uk/geophotos/07/39/36/7393679_a8853fb1_original.jpg&autoLoad=true

The image is 12500 x 6250 px (equirectangular). But I understand many mobile devices have a max-texture size of 4096, so it wont load on such devices (the inbuilt splitting into two textures would allow 8192px width)
... so conceptually, thinking could check what size supported (before loading pannellum), and get a max-resolution version instead, ie have the server generate a 8192px x 4096px and use that in the viewer. Need a way to know what will load.

Here it is in our own viewer
https://www.geograph.org.uk/pano.php?id=7393679&debug=1
(the 'debug' adds the detail at the top, which shows the maxwidth based on gl.MAX_TEXTURE_SIZE
Extracted from

maxWidth = gl.getParameter(gl.MAX_TEXTURE_SIZE);

as well as the 'options' sent to pannellum)

However, my own device, which reports "supported size is 8192px" - ie double MAX_TEXTURE_SIZE. will load the pano!
See screenshot: https://media.geograph.org.uk/files/c81e728d9d4c2f636f067f89cc14862c/Screenshot_20230202_134724.png

Yet, some other devices
https://media.geograph.org.uk/files/5f93f983524def3dca464469d2cf9f3e/Screenshot_2023_02_01_17_04_37_804_com.android.chrome.jpg
report "This panorama is too big for your device! It's 9375px wide, but your device only supports images up to 8192px"

And
https://www.touringcars.net/p1/Screenshot_20230202-142515.png
report "This panorama is too big for your device! It's 10938px wide, but your device only supports images up to 8192px"

Where does 9375px and 10938px come from? And why does another device (also claiming 8192px maxWidth) load the same 12500 x 6250 px image.

Seems can't rely on MAX_TEXTURE_SIZE to say if will load or not.

identify 7393679_a8853fb1_original.jpg
7393679_a8853fb1_original.jpg JPEG 12500x6250 12500x6250+0+0 8-bit sRGB 6.99607MiB 0.000u 0:00.000

THere is no dynamic 'serving' going on (what would downsize the image). The .jpg is coming direct from Amazon S3, via cloudfront.

When Pannellum runs that check, it just uses the width property of the Image object, so the only explanations I can come up with are that you've found a weird browser bug or that your server isn't doing what you think it's doing. Pannellum doesn't do anything to manipulate that value.

However, practically speaking it probably doesn't matter. Maximum texture sizes are powers of two, so you should just scale to 8192px width if the device has a 4096px texture size and your image is larger than 8192px wide. I'm assuming you don't have images wider than 16384px wide (and I'd tend to recommend the multires viewer for images that big).

I have more information to add. The same URL if you open it in chrome and if you open it in "Firefox Focus" it behaves differently.

@Eliaxs1900 What do you mean by "it behaves differently"?