Jump to content

how to debug gamestate starting time?


solinari6
 Share

Recommended Posts

I've got a very simple game that I've been developing using the browser, but am really targeting android and iOS with it.

It has a basic menu state, with a couple buttons like "PLAY" or "OPTIONS".

When you hit the PLAY button, it loads the GAMEPLAY state.  On the browser, this happens almost instantaneously.

On Android, however, there's a good 5-10 second delay before the GAMEPLAY state shows up.  I can't figure out what it's doing ... I'm assuming it is loading things differently than the browser does?  

I have no clue how to debug this, so any tips would be appreciated!

Link to comment
Share on other sites

First, I would deploy my code in Intel XDK project which can export to Cordova/Crosswalk builds.

It depends on what you are running your game on the mobile device. If it is WebView it will be sluggish. Mobile browser should run it well enough, depending on how well is your game designed. Maybe it needs optimization.

But if you want to publish and APK, then I would go with Intel XDK -> Crosswalk build. Crosswalk embeds mobile browser in your game which might add 20MB to the file but it will run smoothly.

Other than that, I would say, Intel XDK has its own features for remote debugging, i.e you can debug your game while the mobile device is attached to your computer. There is a console, you will see real time updates if something breaks, or you can just console.log() what you want.

Check it: Intel XDK

Link to comment
Share on other sites

Hmm, I'm not using XDK (using brackets instead), BUT, I did end up adding crosswalk to the build manually a while ago.

For some reason on Android, the default webview was causing lots of nasty crashes on Samsung phones.  The only way I could get it to stop crashing was to switch to the crosswalk webview.

I do have remote debugging with Chrome set up, but I don't really see it doing anything during those 5-10 seconds of loading.

Link to comment
Share on other sites

When you say 'on the browser', you mean the mobile browser on the same device right?

Webviews are, basically, the same as the browser app but they're not always quite the same, iOS has two different versions that apps can use with wildly differing performance, I'm less clear on Android but some slightly older (like, 1 year or something, I don't have exact OS version numbers to hand) only use Chrome 37 (or similar) for their Webviews even if the device shipped with a new version of Chrome, which is frustrating.

With remote debugging you should be able to track all requests and responses the webview is making, if you're worried about load perf you can check there and do the same thing in the browser on the device, if you're making a lot of requests maybe the browser does them in parallel (as much as possible) whilst the webview is locked to one concurrent request? if this or something similar is the issue there may be some config that would alleviate or at least reduce the problem. Some Android webview (or maybe the OS) versions have issues with certain TLS versions, if any of your requests require newest TLS then you'll have to wait for a downgrade, although I suspect the browser on the device would have the same restriction (but maybe not).

Oh, and welcome to the wonderful world of faking native apps with JS, in theory it sounds possible, or even attractive, in practise you get swamped with little edge-cases and issues like this and some of them will be insurmountable. At least this gets better every day.

Link to comment
Share on other sites

2 hours ago, mattstyles said:

When you say 'on the browser', you mean the mobile browser on the same device right?

No, actually I mean a web browser on my PC.  I'm using "cordova run browser" which launches chrome and lets me test there.  It's much easier than testing on the phone.

Anyway, so I took out the crosswalk plugin to see if that makes any difference.  It did, it starts up now in about 1/2 the time.  That's nice, but i don't think it's a workable solution since it will crash on samsung phones with the default webview :(

I'll have to get the iOS build running and see if it does the same thing ...

Link to comment
Share on other sites

Yeah, for devving using Chrome on your desktop is fine but you can't use it to test performance in any way. If you have a perf issue in app then the first thing you should do is fire it into the mobile browser and compare webview against that.

I didn't realise Crosswalk was slow to load, thats a shame, not sure if you can tell the Play Store which version of your app to target which OS version?

Link to comment
Share on other sites

Ok, so I figured out what is causing the delay, but I'm not sure how to fix it :)

It appears that the google admob ad loading freezes the game until it is done (using the AdMobPro plugin).  It's the "createBanner" function that the game hangs in for 5-10 seconds.

I'm surprised that this sort of thing doesn't automatically happen in the background?  Do I need to somehow tell this function to run in a different thread or something?  Freezing the game for 10 seconds while this runs is pretty strange behavior.

Link to comment
Share on other sites

On 10.4.2017 at 7:47 PM, solinari6 said:

Ok, so I figured out what is causing the delay, but I'm not sure how to fix it :)

It appears that the google admob ad loading freezes the game until it is done (using the AdMobPro plugin).  It's the "createBanner" function that the game hangs in for 5-10 seconds.

I'm surprised that this sort of thing doesn't automatically happen in the background?  Do I need to somehow tell this function to run in a different thread or something?  Freezing the game for 10 seconds while this runs is pretty strange behavior.

The admob plugin loads something(ad image) or it just hangs? Explain more please.

And by the way, admob is an Android plugin or you include it in javascript?

Share some link, which plugin is that you use.

Link to comment
Share on other sites

On 10/04/2017 at 6:47 PM, solinari6 said:

Freezing the game for 10 seconds while this runs is pretty strange behavior.

It is indeed but some plugins are just poorly written. You can get this sort of nastiness in the Cordova ecosystem (for example), its probably mostly because you get devs with little experience of the language trying to write code for it with little knowledge of what they are actually doing, although that might not be the case here.

If the plugin has a git repo then check there for open issues or extra documentation, there may well be a setting to run this in the background and an explanation why it does not do this as default. If you find nothing you might be best off opening an issue on the repo and get help from the people maintaining the plugin.

Link to comment
Share on other sites

I was able to track this down to a bug in the admobpro plugin.  Here's some details:

https://github.com/floatinghotpot/cordova-admob-pro/issues/504

 

Quote

I think the 'stop' problem is related to these issues: #370 (reported by me several months ago) and #403.
I myself still using the older version of the plugin (cordova-plugin-admobpro v2.12.0 and cordova-plugin-extension v1.2.9), the last known version without the stop/freeze problem.
@floatinghotpot Please kindly solve this issue. Thanks.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...