SDKBoxPlay disconnect in background

SDKBoxPlay disconnect in background
0

#1

Hello,

I am using Cocos2dx 3.17 and sdkbox iap (2.4.1.1) and sdkboxplay (2.4.1.1)

I have tried the following versions
‘com.google.android.gms:play-services-:12.0.1’
'com.google.android.gms:play-services-
:15.0.1’
'com.google.android.gms:play-services-:16.0.0’
and the problem is the same. (
auth, ads, games, drive)

I have gone over the checklist multiple times

I have tested on both an older android 4.4.2 device and an android 7.1.1 device

connect_on_start=false

When I call signin shortly after my game starts I can connect to google play. It always asks to choose account (this might be some other problem, I would like it to login without this), but I still login successfully.

I can then access the leaderboards successfully. But when I hit the home button (minimize the game) I get a onConnectionStatusChanged(1001). When bringing the app to the foreground, no other connection messages are given. I can then call signin (from a button in the game) which will successfully log me back in (again prompting me to choose an account). Any help would be appreciated resolving this issue.

Here is the logcat when I minimize

24344-24344/com.mycompany.mygame D/Cocos2dxActivity: onPause()
24344-24964/com.mycompany.mygame V/FA: Recording user engagement, ms: 136632
24344-24964/com.mycompany.mygame V/FA: Activity paused, time: 171376882
563-902/? I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from android.media.AudioManager$4205e760org.cocos2dx.lib.Cocos2dxAudioFocusManager$1$42192800
733-733/? V/KeyguardUpdateMonitor: handleSetGenerationId(g=130, clear=true)
24344-24344/com.mycompany.mygame D/AudioFocusManager: abandonAudioFocus succeed!
24344-24344/com.mycompany.mygame I/API: onPause()
24344-24390/com.mycompany.mygame D/cocos2d-x debug info: cocos_audioengine_focus_change: 0
24344-24390/com.mycompany.mygame D/cocos2d-x debug info: cocos_audioengine_focus_change : cocos_audioengine_focus_change: AudioEngineImpl isn't ready!
24344-24390/com.mycompany.mygame D/cocos2d-x debug info: Suspended
563-988/? V/WindowManager: rotationForOrientationLw(orient=-1, last=0); user=0  sensorRotation=-1 mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false gripRotationLock=false
563-656/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1509 com.android.internal.policy.impl.PhoneWindowManager.notifyToSSRM:5955 com.android.internal.policy.impl.PhoneWindowManager.access$200:188 com.android.internal.policy.impl.PhoneWindowManager$PolicyHandler.handleMessage:735 android.os.Handler.dispatchMessage:102 
884-884/? D/Launcher.Workspace: exitWidgetResizeMode State: NORMAL, newDragStarted: false
884-884/? D/Launcher: onRestart, Launcher: 1105926080
884-884/? D/Launcher: onStart, Launcher: 1105926080
884-884/? D/Launcher.HomeView: onStart
884-884/? D/Launcher: onResume, Launcher: 1105926080
884-884/? D/Launcher.HomeView: onResume
733-733/? D/PhoneStatusBar: setSemiTransparentMode=false, mTransparentMode=false, mSemiTransparentMode=false, mMultiWindowMode=false
733-733/? D/PhoneStatusBar: setTransGradationMode=false, mTransparentMode=false, mSemiTransparentMode=false, mMultiWindowMode=false
884-884/? D/MenuAppsGridFragment: onResume
1171-1171/? I/MultiWindowTrayService: mHomeResumeReceiver : onReceive
1171-1171/? I/Sally Service: removeWindow window
24775-24775/? V/TaskCloserActivity: TaskCloserActivity onReceive() - com.sec.android.intent.action.HOME_RESUME
24344-24964/com.mycompany.mygame D/dalvikvm: GC_FOR_ALLOC freed 2372K, 40% free 12551K/20732K, paused 68ms, total 68ms
24344-24344/com.mycompany.mygame D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=false
563-24974/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1509 com.android.server.InputMethodManagerService$4.run:2684 java.lang.Thread.run:841 <bottom of call stack> <bottom of call stack> 
24344-24390/com.mycompany.mygame D/cocos2d-x debug info: PlayListener::onConnectionStatusChanged 1001
7404-7961/? W/GamesServiceBroker: Client connected with SDK 14536000, Services 14366000, and Games 70890030
24344-24390/com.mycompany.mygame D/cocos2d-x debug info: PlayListener::onConnectionStatusChanged 1001

Here is the logcat when I resume

733-733/? E/ViewRootImpl: sendUserActionEvent() mView == null
24344-24344/com.mycompany.mygame D/Cocos2dxActivity: onResume()
24344-24964/com.mycompany.mygame V/FA: Connecting to remote service
24344-24964/com.mycompany.mygame V/FA: Activity resumed, time: 171383900
563-804/? I/MediaFocusControl:  AudioFocus  requestAudioFocus() from android.media.AudioManager$4205e760org.cocos2dx.lib.Cocos2dxAudioFocusManager$1$42192800
24344-24344/com.mycompany.mygame D/AudioFocusManager: requestAudioFocus succeed
733-733/? V/KeyguardUpdateMonitor: handleSetGenerationId(g=131, clear=true)
24344-24344/com.mycompany.mygame I/API: onResume()
143-143/? I/SurfaceFlinger: id=1099 createSurf (800x1280),1 flag=4, TurfaceView
143-143/? I/SurfaceFlinger: id=1100 createSurf (800x1280),1 flag=4, BppActivity
563-4866/? I/SpenGestureManager: setFocusWindow21025
24344-24344/com.mycompany.mygame D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=true
24344-24390/com.mycompany.mygame D/EngineDataManager.cpp: setAnimationInterval by engine: 0.0083
24344-24390/com.mycompany.mygame D/EngineDataManager.cpp: JNI setAnimationInterval: 0.008333
24344-24460/com.mycompany.mygame W/libOpenSLES: Leaving Object::GetInterface (SL_RESULT_FEATURE_UNSUPPORTED)
563-24990/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1509 com.android.server.InputMethodManagerService$4.run:2684 java.lang.Thread.run:841 <bottom of call stack> <bottom of call stack> 
563-656/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1509 com.android.internal.policy.impl.PhoneWindowManager.notifyToSSRM:5955 com.android.internal.policy.impl.PhoneWindowManager.access$200:188 com.android.internal.policy.impl.PhoneWindowManager$PolicyHandler.handleMessage:735 android.os.Handler.dispatchMessage:102 
24344-24964/com.mycompany.mygame V/FA: Connection attempt already in progress
24344-24964/com.mycompany.mygame D/FA: Connected to remote service
24344-24964/com.mycompany.mygame V/FA: Processing queued up service tasks: 2

#2

I’ve continued to try everything I can think of, still no luck. User is disconnected when minimizing the app. I even tried using SdkboxPlay 2.4.1.0 from the example app and that didn’t work either.

Additionally, I’m trying to get cloud saves into the game. On iOS, it has worked with no problems, but on android I get the following in LogCat

E/SdkboxPlay: cloud save is disable

I have “Saved Games on” in the game services console.

Any help would be great.


#3
  1. user is disconnected when minimizing app
    we will look inot this.

  2. cloud save is disable
    please enable cloud save in sdkbox_config.json

{
    "android": {
        "sdkboxplay": {
            ...
            "cloud_save": true
        }
    },
    ....
}


#4

Thanks for your help, cloud saving is now working on Android. I would recommend updating the SdkboxPlay integration guide with this info, because I follow that when installing/updating plugins.

For your info, onSaveGameData is passing “success=false” on Android, even though it seems to be saving just fine (I’m able to sync two devices with my save data).

Also, thank you for continuing to investigate the problem of disconnecting google play in the background. I’d be happy to give any further information, should you need it.


#5

the error string is empty?

how to reproduce this? every time is false?


#6

Yes, the error string is empty and every time the function was called, success was false. But it must be saving, because I was able to sync 2 devices.

I’m not at work right now, so I can only give a general overview, but I know the steps are as follows:

Request the files
Wait for file name callback
If file exists, load the file
Wait for load callback
Merge data
Call save data
Wait for callback (on Android only, success claims false)

I can give more info in about 11 hours :grinning:

EDIT:
Here are the specific calls on Android

sdkbox::PluginSdkboxPlay::fetchGameDataNames();
MyListener::onGameDataNames() > one name in list, example "game.save"
sdkbox::PluginSdkboxPlay::loadOneGameData("game.save");
MyListener::onLoadGameData() > savedGameData != null, data is good
MyListener::onLoadGameData() > savedGameData == null, error string is empty   // Not sure why this comes in, I ignore it
//
// Here I update some data
//
sdkbox::PluginSdkboxPlay::saveGameDataBinary("game.save",pData,dataLength);
MyListener::onSaveGameData() > success==false, error string is empty (save is actually successful)

#7
  1. success=false
    this is a bug, we fix it in next release.

  2. disconnect in background

please try this:

PluginSdkboxPlay.jar.zip (78.7 KB)


#8

Thanks very much, this seems to be working great. I can minimize/resume with no connection loss. Plus, it has stopped asking to choose an account when starting the game (awesome). Cloud saving continues to work (the success=false issue won’t pose a problem until next release)

Will these fixes be in the next release? Can I use this jar file in production?

Thanks again.


#9
  1. you can use this jar in production.
  2. this fixed will be in the next release.

#10

@htlxyz
We released the game…it is crashing 100% on some devices.

com.google.android.gms.tasks.RuntimeExecutionException: 
  at com.google.android.gms.tasks.zzu.getResult (Unknown Source)
  at com.sdkbox.plugin.SdkboxGPGSavedGames.processSnapshotsClientTask (SdkboxGPGSavedGames.java:294)
  at com.sdkbox.plugin.SdkboxGPGSavedGames.access$400 (SdkboxGPGSavedGames.java:28)
  at com.sdkbox.plugin.SdkboxGPGSavedGames$8$1.onComplete (SdkboxGPGSavedGames.java:429)
  at com.google.android.gms.tasks.zzj.run (Unknown Source)
  at android.os.Handler.handleCallback (Handler.java:751)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6123)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:867)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:757)

I tested it before release (uploading directly to a device) and I also got this crash. I decided to test it by downloading it from the play store and I didn’t get the crash. I would really appreciate some help solving this, the game is live now.


#12

yes, we are research this. will fix in next release. thanks really…