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

Do not remove crossOrigin property. #90

Closed
wants to merge 1 commit into from

Conversation

golenkovm
Copy link

Hi @icc

We're having an issue displaying some h5p avtivities with Objectfs Pre-Signed feature enabled (this feature allows you to grant temporary access and lets users to download resourses directly from S3 bucket).

For example, https://h5p.org/virtual-tour-360 looks like:
image

Error from console:

THREE.WebGLState: DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The image element contains cross-origin data, and may not be loaded.
    at Object.texImage2D (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2228:505)
    at z (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2241:146)
    at Ug.u [as setTexture2D] (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2235:121)
    at de.setTexture2D (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2315:325)
    at Cg.mg [as setValue] (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2164:87)
    at Function.eb.upload (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2741:135)
    at t (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2292:226)
    at de.renderBufferDirect (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2307:576)
    at q (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2277:439)
    at m (https://sandbox.local/pluginfile.php/1/mod_hvp/cachedassets/6fbeb1fa452bb8721948e8ba1897f3403dc4e01c.js:2277:133)

We could fix the issue by setting element.crossOrigin to a random value (empty string or eg anonymous). I've found this method was introduced by you as part of this commit.

Is there any objections to get this pr merged? Or maybe you have a better solution.

Thanks,
Mikhail

@icc
Copy link
Member

icc commented Jul 16, 2020

Yes, unfortunately, this will break other parts of H5P that require this property to be reset.

To keep the crossOrigin property set you can either use the H5PIntegration.crossorigin and H5PIntegration.crossoriginRegex to achieve the property you need for certain sources, or you can override the H5P.setSource if you want it only for a specific element, however, just defining the first two should get you what you need.

In the plugins there should already be config options you can set for these, e.g. in Moodle:

$CFG->mod_hvp_crossorigin = 'anonymous';
$CFG->mod_hvp_crossoriginRegex = '^https?:\/\/yourcdn.domain.com';

which will give you anonymous for all sources leading to your CDN.

@icc icc closed this Jul 16, 2020
@golenkovm
Copy link
Author

That did work. Thank you so much @icc

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

Successfully merging this pull request may close these issues.

2 participants