[SOLVED] iPhone & iPad laced with security errors

iPhone & iPad stopped working due to security errors

originated from playcanvas-stable.min.js

The error means the image your are trying to use is loaded by some method that iOS considers not secure. Maybe loading from a local file system? Is this a self-hosted build? You could try to use a debug version of the engine to see the logs that make more sense and add breakpoints. If you have a small repro project, that would help as well.

Edit:
Maybe relevant:

1 Like

ok. we solved this problem.

It was CORS problem. Reading off an image from a url. The following way correctly
reading an image out of a URL without a security problem in iPhone & iPad.

let loadPromises = this.myWorlds.map((world, index) => {
    var self = this;
    let imageUrl = 'IMAGE URL ADDRESS';
    return new Promise((resolve, reject) => {
        let img = new Image();
        img.crossOrigin = 'anonymous'; // Set crossOrigin for CORS
        img.onload = () => {
            // Assuming the framework allows creating a texture from an Image object
            let texture = new pc.Texture(self.app.graphicsDevice);
            texture.setSource(img);
            WorldMenu.instance.worldImages[index] = texture;
            resolve();
        };
        img.onerror = (error) => {
            console.log("can't load " + imageUrl);
            console.error(error);
            WorldMenu.instance.worldImages[index] = null;
            resolve(); // Resolve even if there's an error
        };
        img.src = imageUrl;
    });
});


// Wait for all Promises to complete
await Promise.all(loadPromises);
2 Likes

We are having the same problem all over again, and the upper mentioned solution is not helping at this point. Oh, well.

This looks like a CORS issue related to how your assets are served. You should take a look at your hosting and ensure it’s providing the correct headers