[r169] OnReady inconsistant in facebook plugin

0 favourites
  • 6 posts
From the Asset Store
Star Maze
$11 USD
Fully Construct 3 game with HTML5 and Facebook instant game files ready to use on Website and Facebook.
  • Problem Description

    The OnReady trigger will never be... triggered... if the facebook API is ready before the first call to the on start of layout.

    I believe it's because, in the runtime Runtime.prototype.trigger function, you're preventing any trigger to fire if the sheet isn't active yet

    Attach a Capx

    Since the facebook plugin depends on a facebook id and the example is very small, I'll just post an image

    Description of Capx

    Either trigger both console log action, or only the OnReady if the facebook API takes time to load

    Steps to Reproduce Bug

    • press F5 or Ctrl+F5
    • look at the console output

    Observed Result

    Kind of race condition.

    Expected Result

    Either:

    The facebook plugin call the window.fbAsyncInit before the start of layout

    which should result in the OnReady being triggered, or put on hold to be triggered just after the start of layout

    -> this is the problem

    Or:

    The facebook plugin call the window.fbAsyncInit after the start of layout

    In this case, the onReady not being true, the part in the on start of layout will not execute

    The OnReady is triggered

    -> this is already working as expected

    Of course, a simple thing to do for now would be

    Facebook: isReady
    System: trigger once
         -> do things[/code:10wumhtn]
    
    [b]Construct 2 Version ID[/b]
    r169
  • I can't reproduce any problem - I tried refreshing several times and it always triggered 'On ready' (and was never true with 'Is ready' on Start of Layout). There shouldn't be a race condition either because it only initialises the Facebook API in the object's instance onCreate - so the layout is already running and it is already allowed to trigger. So even if it initialises instantly it should still trigger correctly.

    I'm not quite clear from your report: is the problem that 'On ready' does not trigger, or it triggers late? If it triggers at all, it's working correctly.

  • Sorry if it wasn't clear, in the test I ran, sometimes, On ready wasn't triggered and Is Ready returned true on start of layout. I'll try to investigate. And if I can reproduce it I'll get back to you with more detail on my settings and a capx.

    I'm a bit new to the facebook app creation, maybe I did something wrong setting some parameters in the facebook dev stuff.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I have seen this as well. The FB load is done very fast and the trigger comes before the layout is running. As a workaround I set up a tick to wait for the layout to start.

    window.fbAsyncInit = function() {
    ....
    // Delay OnReady event so layout is loaded before trying to do events
    fbRuntime.tickMe(fbInst);
    };
    
    instanceProto.tick = function () {
    	// Just do this once after load
    	if (fbRuntime.running_layout) {
    		fbRuntime.untickMe(fbInst);
    		fbReady = true;
    		fbRuntime.trigger(cr.plugins_.FacebookFE.prototype.cnds.OnReady, fbInst);
    	}		
    };
    
    [/code:2glnduyl]
  • Yeah I do confirm, I remade the test with the exact same two events discribed above.

    To be more precise, I exported the project and hosted it as a canvas app embedded in a page.

    When I load the game the first time, I get Onready, but If I just F5, the OnReady isn't triggered (Ctrl+F5 sometimes triggers the OnReady)

    I believe the js being in the cache, it's loaded so fast that the call to fbAsyncInit is done before the call to the system OnLayoutStart.

    And I do believe that each OnCreate of each instances of object type are called before the OnLayoutStart so everything is initialized at this point, including the facebook API js added to the page. So the racing condition is quite possible.

    Arne 's solution seems ok to me

    ( Ashley maybe, if you end up modifying the plugin, you could also expose a bit more data in expressions, like the fbAppID ... For now I have to hard code the link the the apps' page (In which I have a like to unlock) for my share button, If I can access the ID directly in runtime I can generate it using events )

  • Ah, I forgot Facebook is a singleglobal and calls onCreate before a layout is ready. So it's true if it's ready very quickly it could try to fire 'On ready' when there is no layout so the trigger is lost. I've fixed it for the next build so it will trigger on the first tick if it's ready and hasn't triggered already. Hopefully that will fix it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)