viser icon indicating copy to clipboard operation
viser copied to clipboard

Latest version seems broken on windows

Open sam598 opened this issue 1 year ago • 4 comments

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.

sam598 avatar Jul 29 '24 22:07 sam598

Hello, thanks so much for reporting!

To clarify:

  • Does this happen even when you install via pip?
  • Is this reproducible across different web browsers? Would you be able to share which one you're using?

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.

brentyi avatar Jul 30 '24 00:07 brentyi

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

sam598 avatar Jul 30 '24 00:07 sam598

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.

brentyi avatar Jul 30 '24 11:07 brentyi

@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,
}

quentin-dietz avatar Sep 23 '24 22:09 quentin-dietz