Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70323

Core H5p doesn't support crossorigin

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Reopened
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.3, 3.10, 3.11, 4.0
    • Fix Version/s: None
    • Component/s: H5P
    • Testing Instructions:
      Hide

      Default storage testing

      1. Access Site administration > H5P > H5P settings.
      2. Confirm, that H5P crossOrigin setting is set to an empty string by default.
      3. Add a core H5P activity Virtual Tour (360). Activity content can be downloaded from https://h5p.org/virtual-tour-360
      4. Open activity page.
      5. Confirm, that activity is displayed correctly.
      6. Access Site administration > H5P > H5P settings.
      7. Set H5P crossOrigin setting to anonymous.
      8. Open activity page.
      9. Confirm, that activity is displayed correctly.

      External storage testing (optional)

      1. Install tool_objectfs plugin: https://github.com/catalyst/moodle-tool_objectfs.git
      2. Configure S3 as an external storage as described here: https://github.com/catalyst/moodle-tool_objectfs#installation
      3. Configure Pre-signed URLs with CloudFrond signing method as described here: https://github.com/catalyst/moodle-tool_objectfs#pre-signed-urls-settings
      4. Set H5P crossOrigin setting to an empty string.
      5. Confirm, that activity is broken as described in this tracker.
      6. Set H5P crossOrigin setting to anonymous.
      7. Confirm, that activity is displayed correctly.
      Show
      Default storage testing Access Site administration > H5P > H5P settings. Confirm , that  H5P crossOrigin  setting is set to an empty string by default. Add a core H5P activity Virtual Tour (360). Activity content can be downloaded from https://h5p.org/virtual-tour-360 Open activity page. Confirm , that activity is displayed correctly. Access Site administration > H5P > H5P settings. Set  H5P crossOrigin  setting to anonymous . Open activity page. Confirm , that activity is displayed correctly. External storage testing (optional) Install tool_objectfs plugin: https://github.com/catalyst/moodle-tool_objectfs.git Configure S3 as an external storage as described here: https://github.com/catalyst/moodle-tool_objectfs#installation Configure Pre-signed URLs with CloudFrond signing method as described here: https://github.com/catalyst/moodle-tool_objectfs#pre-signed-urls-settings Set  H5P crossOrigin  setting to an empty string . Confirm , that activity is broken as described in this tracker. Set  H5P crossOrigin  setting to anonymous . Confirm , that activity is displayed correctly.
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • Pull from Repository:
    • Pull 3.11 Branch:
      MOODLE_311_MDL-70323
    • Pull Master Branch:
      master-MDL-70323

      Description

      There is an issue with 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 external storage).

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

      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)
      

      Original `mod_hvp` plugin has a couple of settings (mod_hvp_crossorigin and mod_hvp_crossoriginRegex) that could be used to fix the issue:

      https://github.com/h5p/moodle-mod_hvp/blob/59d6605b2be7759f8aa48dd84e697109e060ba61/locallib.php#L80-L81

      But the core activity doesn't have it:

      https://github.com/moodle/moodle/blob/c8d33eb9ceac63135723891d357e59dee6f5d76a/h5p/classes/helper.php#L359

      Setting this in config.php solved the issue with 'mod_hvp':

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

       

        Attachments

          Activity

            People

            Assignee:
            mikhailgolenkov Mikhail Golenkov
            Reporter:
            mikhailgolenkov Mikhail Golenkov
            Peer reviewer:
            Nathan Nguyen Nathan Nguyen
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h