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

OHIF V3 with Orthanc MPR works fine on localhost but SharedArrayBuffer error over internet #3220

Closed
ranasrule opened this issue Mar 6, 2023 · 25 comments

Comments

@ranasrule
Copy link

ranasrule commented Mar 6, 2023

I have been pulling my hair out over the last three days trying to figure this out without any luck.....

Describe the Bug

OHIF V3 with Orthanc MPR functionality works fine on localhost but Error: Uncaught (in promise) Error: SharedArrayBuffer is NOT supported in your browser see https://developer.chrome.com/blog/enabling-shared-array-buffer/ error occurs when accessing over that internet

Steps to Reproduce:

  1. open any study on localhost and switch to MPR view. It will work find
  2. open any study over the internet and switch to MPR view. It will generate Error: Uncaught (in promise) Error: SharedArrayBuffer is NOT supported in your browser see https://developer.chrome.com/blog/enabling-shared-array-buffer/ error in browser console and MPR will not generate.

my nginx config file is below:

worker_processes 1;

events { worker_connections 1024; }

http {

    upstream orthanc-server {
        server 127.0.0.1:8099;
    }

    server {
        listen [::]:8099 default_server;
        listen 8099;

        # CORS Magic
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow_Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';

        location / {
		
			if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow_Credentials' 'true';
                add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
                add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }
			try_files $uri $uri/ /index.html;
			add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Origin' '*';
			add_header Cross-Origin-Opener-Policy same-origin;
			add_header Cross-Origin-Embedder-Policy require-corp;
			add_header Cross-Origin-Resource-Policy same-origin;
				  }
				  
				  
		location /orthanc/{
        
            proxy_pass http://localhost:8042;
            proxy_set_header Authorization "Basic YWxuYXNhcnBhY3MbyybyybNhcnBhY3M1Nzc=";
            proxy_set_header Host $Host:8099/orthanc/;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;

            # CORS Magic
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow_Credentials' 'true';
            add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
            rewrite /orthanc(.*) $1 break;
                           }     		  
    }
}

My app-config.js is below

window.config = {
    routerBasename: "/",
    extensions: [],
    modes: [],
    customizationService: {},
    showStudyList: !0,
    maxNumberOfWebWorkers: 3,
    omitQuotationForMultipartRequest: !0,
    showWarningMessageForCrossOrigin: !0,
    showCPUFallbackMessage: !0,
    showLoadingIndicator: !0,
    maxNumRequests: {
        interaction: 100,
        thumbnail: 75,
        prefetch: 10
    },
    dataSources: [{
        friendlyName: "dcmjs DICOMWeb Server",
        namespace: "@ohif/extension-default.dataSourcesModule.dicomweb",
        sourceName: "dicomweb",
        configuration: {
            name: "aws",
            wadoUriRoot: '/orthanc/wado',
			qidoRoot: '/orthanc/dicom-web',
			wadoRoot: '/orthanc/dicom-web',
            qidoSupportsIncludeField: !1,
            supportsReject: !1,
            imageRendering: "wadors",
            thumbnailRendering: "wadors",
            enableStudyLazyLoad: !1,
            supportsFuzzyMatching: !1,
            supportsWildcard: !0,
            staticWado: !0,
            singlepart: "bulkdata,video,pdf"
        }
    }, {
        friendlyName: "dicom json",
        namespace: "@ohif/extension-default.dataSourcesModule.dicomjson",
        sourceName: "dicomjson",
        configuration: {
            name: "json"
        }
    }, {
        friendlyName: "dicom local",
        namespace: "@ohif/extension-default.dataSourcesModule.dicomlocal",
        sourceName: "dicomlocal",
        configuration: {}
    }],
    httpErrorHandler: e => {
        console.warn(e.status), console.warn("test, navigate to https://ohif.org/")
    },
    defaultDataSourceName: "dicomweb",
   
};

The current behavior

OHIF V3 with Orthanc MPR functionality works fine on localhost but Error: Uncaught (in promise) Error: SharedArrayBuffer is NOT supported in your browser see https://developer.chrome.com/blog/enabling-shared-array-buffer/ error occurs when accessing over that internet

The expected behavior

It should work over the internet as well as localhost

I tried using the example nginx config file here as a guide >>> https://github.com/OHIF/Viewers/blob/master/.docker/Nginx-Orthanc/config/nginx.conf but no luck.

@ranasrule ranasrule added Awaiting Reproduction Can we reproduce the reported bug? Community: Report 🐛 labels Mar 6, 2023
@ranasrule
Copy link
Author

Anyone?

@ranasrule
Copy link
Author

please?

@daker
Copy link

daker commented Apr 17, 2023

have you tried putting the headers inside single quotes ? like this ?

location / {
        try_files $uri /index.html;
        add_header 'Cross-Origin-Embedder-Policy' 'require-corp';
        add_header 'Cross-Origin-Opener-Policy' 'same-origin';
}

@ranasrule
Copy link
Author

have you tried putting the headers inside single quotes ? like this ?

location / {
        try_files $uri /index.html;
        add_header 'Cross-Origin-Embedder-Policy' 'require-corp';
        add_header 'Cross-Origin-Opener-Policy' 'same-origin';
}

is https required or will this work with simple hppt over the internet ?

@daker
Copy link

daker commented Apr 18, 2023

it should work with http

@arunjoshtech
Copy link

have you tried putting the headers inside single quotes ? like this ?

location / {
        try_files $uri /index.html;
        add_header 'Cross-Origin-Embedder-Policy' 'require-corp';
        add_header 'Cross-Origin-Opener-Policy' 'same-origin';
}

is https required or will this work with simple hppt over the internet ?

Dear Ranasrule,
Have you resolved the issues, I am also facing same issues. Please advise

@arunjoshtech
Copy link

we tried with with add header but it is not giving result. kindly advise on it to make it work

@sedghi
Copy link
Member

sedghi commented Sep 29, 2023

@jbocce Do you know what is going on here? I believe it is the secure context problem.

@jbocce
Copy link
Contributor

jbocce commented Sep 29, 2023

@jbocce Do you know what is going on here? I believe it is the secure context problem.

At first glance, I would say that the problem is that a secure context has not been established. So to answer a previous question from @ranasrule, https IS required over the internet.

@ranasrule
Copy link
Author

ranasrule commented Sep 29, 2023 via email

@sedghi
Copy link
Member

sedghi commented Sep 29, 2023

@ranasrule
Copy link
Author

ranasrule commented Sep 29, 2023 via email

@sedghi
Copy link
Member

sedghi commented Sep 29, 2023

You can still use the StackViewport, however, if you want Volume rendering, you should be in a secure context. Just want to point out the decision of ONLY allowing SharedArrayBuffer to run in a secure context is by World Wide Web Consortium group and not OHIF

@ranasrule
Copy link
Author

ranasrule commented Sep 29, 2023 via email

@sedghi
Copy link
Member

sedghi commented Sep 29, 2023

You can turn it off but it would be slower, just FYI (maybe I should have mentioned it in the previous reply)

useSharedArrayBuffer here https://docs.ohif.org/configuration/configurationFiles

ps: where is the link to your plugin for volview?

@ranasrule
Copy link
Author

ranasrule commented Sep 29, 2023 via email

@ranasrule
Copy link
Author

You can turn it off but it would be slower, just FYI (maybe I should have mentioned it in the previous reply)

useSharedArrayBuffer here https://docs.ohif.org/configuration/configurationFiles

ps: where is the link to your plugin for volview?

setting useSharedArrayBuffer to false gives the following error even when loading the study in non mpr mode

Screenshot 2023-09-30 010940

@sedghi
Copy link
Member

sedghi commented Sep 29, 2023

Check this PR out, it will fix that bug after merge

#3686

@ranasrule
Copy link
Author

Check this PR out, it will fix that bug after merge

#3686

still getting the same issue even after merging of #3686

Screenshot 2023-09-30 141457

@sedghi
Copy link
Member

sedghi commented Oct 2, 2023

There is a very good chance you are saying false (boolean) while it should be string. I have another PR to fix this to support boolean too https://github.com/OHIF/Viewers/pull/3688/files

If you see the memory snapshot there is not sharedArrayBuffer

CleanShot 2023-10-02 at 10 32 52

@sedghi sedghi removed the Awaiting Reproduction Can we reproduce the reported bug? label Oct 2, 2023
@ranasrule
Copy link
Author

ranasrule commented Oct 2, 2023

@sedghi I have set useSharedArrayBuffer: "FALSE" as you suggest but with the same results as you can see in the screenshots below

Screenshot 2023-10-03 035107

image

One more thing...I have no idea if this has anything to do with the issue under discussion but Im also getting the error in the screenshot below in the browser console:

image

@sedghi
Copy link
Member

sedghi commented Oct 3, 2023

You are putting it in a wrong location, it should be the root of the configuration

@ranasrule
Copy link
Author

You are putting it in a wrong location, it should be the root of the configuration

Perfect...working great now. Thank you for all your contributions to this great project.

@mrceresa
Copy link

mrceresa commented Feb 6, 2024

Dears,
thanks for all the information provided both here and in the docs.

I have two questions (additional details here):

  • any way to get a secure context with cors if I have orthanc and ohif on separate domains? As of now when I enable same-origin it stops loading the dicoms
  • my useSharedArrayBuffer = 'FALSE' seems to be ignored, do you have additional information on how to debug this?
window.config = {
  routerBasename: '/',
...
  useSharedArrayBuffer: 'FALSE',
...

Thanks and regards

@sedghi
Copy link
Member

sedghi commented Feb 20, 2024

@mrceresa see our docs https://docs.ohif.org/deployment/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants