Cocos2d-JS 3.14.1 Facebook canvas issue?

Cocos2d-JS 3.14.1 Facebook canvas issue?
0.0 0

#1

Hi,

I wanted to check - some time ago we developed game on cocos2d-JS 3.8 which was working with no issues in Facebook canvas.

Today we experimented with Cocos2d-JS 3.14 version and seems something was changed in core as getting following error in console when trying access game in Facebook canvas. If using direct site link everything works.

Uncaught DOMException: Blocked a frame with origin "https://mygamesite.com" from accessing a cross-origin frame.
    at f.visit (https://mygamesite.com/game.min.js:486:424)
    at f.visit (https://mygamesite.com/game.min.js:483:167)
    at f.visit (https://mygamesite.com/game.min.js:378:109)
    at f.drawScene (https://mygamesite.com/game.min.js:605:454)
    at f.mainLoop (https://mygamesite.com/game.min.js:617:301)
    at b (https://mygamesite.com/game.min.js:53:99) 

Not sure if it is core issue or some part of our code. Is there confirmation that 3.14 version working with Facebook Canvas? It seems like included JS code trying to access something in Facebook Canvas and browser blocking it.

@slackmoehrle
Could you please check with team this issue, I was testing right now hello world project and it doesn’t load in Facebook canvas stuck on console error. Also what strange even project generated with cocos2d-x 3.14.1 in console JS showing 3.14.


#2

pfff found solution ;/

In your project open the following file:
frameworks/cocos2d-html5/cocos2d/core/layers/CCLayer.js
then on line 250 change
visit: function () {
to 
visit: function (parent) {

Actually this is like a typo, developers just missed to name the parameter in the function, and because by default window.parent is the parent frame, the error occurs because your game is trying to request the parent frame which is forbidden on facebook.

@slackmoehrle please ask devs to fix that issue and also correct JS engine version in 3.14.1


#3

@energyy Thanks. I am passing this along.


#4

Thanks, it was indeed a typo during refactorization of visit process, and it has been fixed in develop branch.
Sorry for the inconvenient