Google Play Services causing FPS drop in game. Is the problem on our end?

So we’re at the stage in development where we are testing the game services. But we noticed that after we had signed in using Google Play Services, we had a pretty bad FPS drop. We’ve been looking at the code and so far everything matches up to what has been suggested in the tutorials. The code is being placed in the main.lua class. Our game and optimized fairly well. Running at 1.67 Physical, and 57.1 Texture. The client runs smooth as butter when game services is not implemented in the code. I have seen others have this problem in other posts, but I’ve also seen games run great using Google. Does anyone have an idea of whats going on? I’ll post the code we have so far below. This is located in our main.

local gameNetwork = require( "gameNetwork" ) local playerName local function loadLocalPlayerCallback( event ) playerName = event.data.alias --saveSettings() --save player data locally using your own "saveSettings()" function end local function gameNetworkLoginCallback( event ) gameNetwork.request( "loadLocalPlayer", { listener=loadLocalPlayerCallback } ) return true end local function gpgsInitCallback( event ) gameNetwork.request( "login", { userInitiated=true, listener=gameNetworkLoginCallback } ) end local function gameNetworkSetup() if ( system.getInfo("platformName") == "Android" ) then gameNetwork.init( "google", gpgsInitCallback ) --print("logged!!!") else gameNetwork.init( "gamecenter", gameNetworkLoginCallback ) end end ------HANDLE SYSTEM EVENTS------ local function systemEvents( event ) print("systemEvent " .. event.type) if ( event.type == "applicationSuspend" ) then print( "suspending..........................." ) elseif ( event.type == "applicationResume" ) then print( "resuming............................." ) elseif ( event.type == "applicationExit" ) then print( "exiting.............................." ) elseif ( event.type == "applicationStart" ) then gameNetworkSetup() --login to the network here end return true end Runtime:addEventListener( "system", systemEvents )

The lag occurs when the sign-in for Google is implemented. So if you cancel the sign in, it occurs. When you sign in, it occurs. I’ve also tried putting it into another class other than the main, and still lags. The code does work though. We are able to use our game services like achievements and leader board. Just there is a huge FPS problem that is breaking the game.

Thanks for reading.

Also, here is some additional information. I am currently building the game using our release keystore. All the information regarding the account has been tested and checked. The client type I am using to build the game is the free pro build. I’m not sure if this would contribute in anyway or not because I have an enterprise account, and I noticed that there is a Google plugin in the plugin folder provided when using enterprise. But when using Pro, there is no plugin folder provided. Right now I have to use the pro version as I am away on vacation. Could the issue be that I do not have the Google Services plugin in my folder? Or is it fully integrated into Corona already?

So far I have tried debugging the game as much as I can. Here is a list of things I have done, and their results.

Debug Attempt #1:

     - Take gameNetwork functions out. Result: Works flawlessly.

     - Reduced FPS setting to make sure it is not load on the phone. Result: Made it worse.

     - Made a local function to hold all the gameNetwork functions in the main.lua. Result: No change in performance.

          FPS drop persists.

     - Turned off all Google Play Services notification settings. Result: No change in performance. FPS drop persists.

     - Added a print(“Test”) function to systemEvents to make sure the function was not getting called every frame

          refresh and eating up physical memory. Result: No change in performance. FPS drop persists.

     - Take gameNetwork code out of main.lua, put it in its own class and call before the game loads. Result: No change

          in performance. FPS drop persists.

You say you put it in a different module, have you tried putting it into an “intro scene” or your “menu scene”? 

I’m not at home so i can’t check my code, but that looks pretty much like the basic code for GPGS login logic.

Could you please post your build.settings? At least the relevant part.

Also, what phone are you using to test it? Can you try it on a different phone?

Logcat could also be useful to check if something else is failing.

The lag occurred on my Galaxy S6 Edge and S4. I actually did just that, sort of. The code remains in the main.lua, but I removed the composer.loadScene() functions from it. I noticed something fishy when I made the character die and I reloaded the scene from the death menu. The lag would suddenly go away. Once I made a new transition class, it now works fine. Just needed a little more testing. Thanks for letting me know about Logcat! I was looking for a way to debug on my phone. Also, thanks for taking time out of your day to respond to my thread. I wasn’t sure if I “formatted” my topic wrong to warrant no reply’s.

Also, here is some additional information. I am currently building the game using our release keystore. All the information regarding the account has been tested and checked. The client type I am using to build the game is the free pro build. I’m not sure if this would contribute in anyway or not because I have an enterprise account, and I noticed that there is a Google plugin in the plugin folder provided when using enterprise. But when using Pro, there is no plugin folder provided. Right now I have to use the pro version as I am away on vacation. Could the issue be that I do not have the Google Services plugin in my folder? Or is it fully integrated into Corona already?

So far I have tried debugging the game as much as I can. Here is a list of things I have done, and their results.

Debug Attempt #1:

     - Take gameNetwork functions out. Result: Works flawlessly.

     - Reduced FPS setting to make sure it is not load on the phone. Result: Made it worse.

     - Made a local function to hold all the gameNetwork functions in the main.lua. Result: No change in performance.

          FPS drop persists.

     - Turned off all Google Play Services notification settings. Result: No change in performance. FPS drop persists.

     - Added a print(“Test”) function to systemEvents to make sure the function was not getting called every frame

          refresh and eating up physical memory. Result: No change in performance. FPS drop persists.

     - Take gameNetwork code out of main.lua, put it in its own class and call before the game loads. Result: No change

          in performance. FPS drop persists.

You say you put it in a different module, have you tried putting it into an “intro scene” or your “menu scene”? 

I’m not at home so i can’t check my code, but that looks pretty much like the basic code for GPGS login logic.

Could you please post your build.settings? At least the relevant part.

Also, what phone are you using to test it? Can you try it on a different phone?

Logcat could also be useful to check if something else is failing.

The lag occurred on my Galaxy S6 Edge and S4. I actually did just that, sort of. The code remains in the main.lua, but I removed the composer.loadScene() functions from it. I noticed something fishy when I made the character die and I reloaded the scene from the death menu. The lag would suddenly go away. Once I made a new transition class, it now works fine. Just needed a little more testing. Thanks for letting me know about Logcat! I was looking for a way to debug on my phone. Also, thanks for taking time out of your day to respond to my thread. I wasn’t sure if I “formatted” my topic wrong to warrant no reply’s.

Did you find a solution for this?

I’m having a similar problem.

I found that when I show achievements or leaderboard from google play services, seems that Corona needs to reload or refresh all the loaded images when appear on screen and a lag happens.

Thank you

Did you find a solution for this?

I’m having a similar problem.

I found that when I show achievements or leaderboard from google play services, seems that Corona needs to reload or refresh all the loaded images when appear on screen and a lag happens.

Thank you