nerfstudio-project / viser

Web-based 3D visualization + Python
https://viser.studio/latest
Apache License 2.0
827 stars 49 forks source link

Latest version seems broken on windows #256

Open sam598 opened 3 months ago

sam598 commented 3 months ago

When installing the latest version of viser through nerfstudio, gsplat, or even building directly from this repository I run into the same error.

:8080/assets/index-DhZhcn5r.js:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

The server loads, however the webpage appears white.

This doesn't seem to be an issue with 0.2.0 or earlier.

brentyi commented 3 months ago

Hello, thanks so much for reporting!

To clarify:

We have some folks at Berkeley who've been using Windows and haven't had problems, and I'm also not aware of any changes that would impact this. But I can try to fix if we're able to reproduce it.

sam598 commented 3 months ago

I'm using chrome on windows.

It happens when installing from pip, or the latest version of nerfstudio from source. Installing nerfstudio from pip seems to install a much older version of viser. I had to directly call pip install viser==0.2.0 to get it to work with gsplat 1.1.1

brentyi commented 3 months ago

I installed Parallels to check in Windows and wasn't able to reproduce in Chrome or Edge with Python 3.10~3.12.

Looking at the code it also doesn't seem like anything has changed that would cause the MIME type to break (this is how it's determined), so I unfortunately don't have a fix... if you have any other information for reproducing that could also be helpful.

quentin-dietz commented 1 month ago

@sam598 we figured out that this is caused by the windows registry not having a content type definition for .js file type, other users report the same issue.. We fixed it by modifying the code here to read as follows:

mime_type = mimetypes.guess_type(relpath)[0]
if mime_type is None:
    mime_type = "application/octet-stream"
### FIX WINDOWS REGISTRY MIME TYPE ISSUE
if relpath.endswith(".js"):
    mime_type = "application/javascript"
response_headers = {
    "Content-Type": mime_type,
}