[SOLVED] Errors during building

Until recently, there were no problems during the building of the project, but now after building the project does not start. Instead, a simple gray screen and the following errors:

In addition, I tried to build previous versions of the project, with which there were no problems before, but now they have the same error.

What could be the reason for such behavior?

What type of build is this as it looks like you are running a local build but with the file:/// protocol?

Are you trying to run the build by double clicking the index.html file? If so, that doesn’t work unless you pass -allow-file-access-from-file as a command line argument when starting up Chrome.

You will need to run a local server to test builds locally.

I export it to the IOS application, and open the index.html as a local web page using wkwebview.

The CORS issue sounds like an app/view setup issue. With Cordova, extra configuration is needed to be able to serve files from the local file system as seen here: https://developer.playcanvas.com/en/user-manual/publishing/mobile/cordova/#building-for-ios

You may also need to use an older version of the engine (1.36.1) until this PR is merged to a release: https://github.com/playcanvas/engine/pull/2597

Can you try the older version of the Engine first please and see if that fixes the issue?

In the Swift, index.html opens as follows:

var webView: WKWebView = WKWebView()

webView.configuration.preferences.javaScriptEnabled = true
    webView.configuration.preferences.javaScriptCanOpenWindowsAutomatically = true
    webView.configuration.preferences.setValue(true, forKey: “allowFileAccessFromFileURLs”)
    let folder = “export”
    let resourcePath = Bundle.main.resourcePath
    let subdir = URL(fileURLWithPath:resourcePath!).appendingPathComponent(folder, isDirectory: true)
    guard let path = Bundle.main.path(forResource: “index”, ofType: “html”, inDirectory: folder) else {
      print(“no se encontró path”)
    let url = NSURL.fileURL(withPath: path)
    webView.loadFileURL(url, allowingReadAccessTo: subdir)

that is, “allowFileAccessFromFileURLs” allows to open files locally.

Everything worked correctly before, but now new builds, even new and old versions do not run.

I’m not aware of an engine changes recently that would change this as the error message is a browser security issue. It’s not something the PlayCanvas can affect.

This screenshot was taken after running the file locally via Google Chrome on Windows, so it is possible that the error in the image really tells about the lack of browser permission to open files locally. However, when running the iOS build, the behavior is the same, but I can`t look at the console in the ios application to understand what the problem is.
In addition, if I run one of the previous builds, everything also works properly.
So the problem is somewhere in the building process.

If that’s the case, please try using the engine version 1.36.1 (found here: https://code.playcanvas.com/playcanvas-1.36.1.min.js) (After exporting the build from PlayCanvas, replace playcanvas-stable.min.js with the 1.36.1 version).

It’s possible you are running into the same issue that my PR fixes in the next engine release.

I replaced playcanvas-stable.min.js with version 1.36.1 and everything started working.
Thank you very much for the tip.

Thanks for coming back to us. We are hoping to get a new release of the engine out this week which will have the fix for this in it.

Fix has been released: https://twitter.com/playcanvas/status/1339588600212512769

1 Like