defold / extension-fbinstant

Facebook Instant Games extension for the Defold game engine
https://defold.com/extension-fbinstant/
MIT License
38 stars 20 forks source link

Android loads from 0 to 100% instantly instead of showing progress #26

Closed subsoap closed 6 years ago

subsoap commented 6 years ago

Also happens in Chrome so may be easier to debug there.

Other non-Defold based games on Android show loading progress. Loading progress of Defold based games does work on iOS.

AGulev commented 6 years ago

I am not sure that I understand where is the bug. How it looks like for me on android: https://youtu.be/xcCja9jQn6c

subsoap commented 6 years ago

What Android version are you testing on?

I tested on 7.0 @britzl was able to reproduce it

AGulev commented 6 years ago

Android 6.0 Xiaomi redmi note4 Can you try using this link: https://www.facebook.com/instantgames/285409181956230/ ?

subsoap commented 6 years ago

That seems to load properly on Chrome and Android so it must be something different you are doing vs the template html included in the fbinstant extension. Could you check the fbinstant extension bundled version and see where the error is compared to your version?

subsoap commented 6 years ago

I'm checking this now too.

subsoap commented 6 years ago

Could you post your .html template?

subsoap commented 6 years ago

You should test the XOXO example on your phone too to see if it loads properly or not like your card game does.

AGulev commented 6 years ago

yes, of course. I made my own template (didn't use xoxo template) For example in my template I use early FBInstant init.

engine_template.html.zip

AGulev commented 6 years ago

Yes, xoxo game loads 0-100% instantly

subsoap commented 6 years ago

I tested your template and it seemed to make loading work, so need to find what's wrong with the fbinstant extension built in html to make it not work on Android (it works on iOS)

AGulev commented 6 years ago

Maybe the reason is early initialization of SDK ? FBInstant.initializeAsync().then(function() {...})

subsoap commented 6 years ago

I'll test that

subsoap commented 6 years ago

Seems like it could be that, doing more testing.

AGulev commented 6 years ago

This is one of the Best Practice recommendation : Load resources in parallel with initializeAsync https://developers.facebook.com/docs/games/instant-games/best-practices

I save is_already_init variable when loading into Module._instant_inited

FBInstant.initializeAsync().then(function() {
        Module._instant_inited = 1;
})

Then checking is_already_init in lua:

function M.init(callback)
  if tonumber(html5.run("Module._instant_inited")) == 1 then
    callback()
  else
    fbinstant.initialize(function(self, success)
      callback()
    end)
  end
end
subsoap commented 6 years ago

I tested the change and it worked on Chrome and Android for me. So template html should be changed likewise in some way @britzl to follow @AGulev 's way of checking for init


        app_container.style.width = width+"px";
        app_container.style.height = height+"px";

        game_canvas.width = width*dpi;
        game_canvas.height = height*dpi;

        window.console.log("width: " + game_canvas.width + " > "+ game_canvas.style.width)
        window.console.log("height:" + game_canvas.height + " > "+ game_canvas.style.height)
    }

  FBInstant.initializeAsync().then(function() {
    Module._instant_inited = 1;

  });   

    resize_game_canvas();

    window.addEventListener('resize', resize_game_canvas, false);
    window.addEventListener('orientationchange', resize_game_canvas, false);

    </script>
subsoap commented 6 years ago

@britzl I did some more tests for this, I'll submit a pr soon with changes to the api tester and xoxo example.

britzl commented 6 years ago

Released: https://github.com/defold/extension-fbinstant/releases/tag/3.6.0