Unity 2020.3.41f and Instant Games SDK 7.1: Content Security Policy question about loading some file
1

As it is stated in documentation if I have issues with Unity and CSP I should ask them, or change UnityLoader.js file. However since Unity 2020.1 it seems internally UnityLoader class has been changed thus I suspect my issue might not be related. Problem is that the application is stuck at 90% loading and won't load further because it refuses to load a script or at least it seems to be a script with UUID name instead of UnityLoader.js.

I am using Unity 2020.3.41f1 and tried also Unity 2022.3.13f1. In both cases issue persists. I am also properly utilizing FBInstant.initializeAsync and startGameAsync, so I doubt that is an issue either. The game when running from localhost in embedded player, but after uploading on facebook and trying to play it directly in Instant Games it refuses to load.

Here's a log from another issue, but is basically the same, I will provide another log tomorrow when I'm able to rebuild application (this one uses no compresion):

ZCT1_FBIG.loader.js:1 Refused to load the script 'blob:https://apps-973233870876311.apps.fbsbx.com/0dba0016-347d-4813-8a6b-ec432717c3a6' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' *.facebook.com *.facebook.net cdn.mixpnl.com *.google-analytics.com web.localytics.com *.googletagmanager.com *.cloudfront.net *.amazonaws.com *.googleapis.com *.firebaseapp.com *.firebaseio.com *.8686c.com *.cncovs.com *.aliyun.com *.aliyuncs.com *.wsdvs.com *.console.re *.kunlunar.com *.windows.net *.msecnd.net *.anysdk.com cdn.babylonjs.com cdn.trackjs.com cdn.firebase.com *.kochava.com *.akamaized.net *.cocos.com *.playfab.com code.createjs.com *.zdassets.com websdk.appsflyer.com cdnjs.cloudflare.com www.gstatic.com *.azureedge.net *.ibytedtos.com *.bytepluscdn.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Since this is trying to load something as a blob I guess it is indeed a problem with CSP, but it's not UnityLoader, or at least it is not obviously it.

Does anyone know what should I change or where should I look to find a possible problem solution? Maybe someone did figure out how to use Unity with Instant Games properly? Any help is welcome and I'm thankful for any ideas that might come.

Mateusz
Asked about a month ago
Selected Answer
1

I'm adding an answer since this information might help others: after removing some packages from the game and rebuilding it again using Unity 2022.3.29f1 it now properly loads and even works fine. Only thing to make sure it will work is to create custom WebGL template that will properly initialize and start game using FBInstant SDK.

I also changed compression from brotli to gzip, since it seemed brotli was preventing loading. Hope this information helps anyone who reads this.

May 17 at 2:10 AM
Mateusz