GPGS v2 crashes

My app is still in development phase. I am doing the testing

@mysticeti

In my case it’s an error affecting a few hundred devices out of hundreds of thousands of daily users.

As I have said before I can’t reproduce it either. A user with affected device offered to help me.

which corona build are you using?

Version 2019.3468

can you upload your snapshot and login code implementation

local function gpgsSnapshotAfterSaveListener( event ) -- end local function gpgsSnapshotOpenForSaveListener( event ) if not event.isError then local data1 = gpgs.snapshots.getSnapshot (event.snapshotId) local data2 = json.decode( data1.contents.read() ) -- some if then else data1.contents.write( json.encode( savethistable ) ) gpgs.snapshots.save({ snapshotId = event.snapshotId, --description = "Save slot " .. "savedata", listener = gpgsSnapshotAfterSaveListener }) end end gpgs.snapshots.open({ filename = "savedata", create = true, listener = gpgsSnapshotOpenForSaveListener })
create = true,

It’s optional.

If we don’t add this line, it’s true by default? 

--description = "Save slot " .. "savedata",

I have commented this line out.

Could this cause crashes?

Try this code

local function gpgsUploadData()   local function gpgsSnapshotOpenForSaveListener( event )     if not event.isError then       event.snapshot.contents.write(globalData.json.encode( gameData )) -- Write new data as a JSON string into the snapshot       globalData.gpgs.snapshots.save({           snapshotId = event.snapshotId,           description = "Game scores",           image = { filename = "pic.png", baseDir = system.ResourceDirectory },         })     end   end -- gpgsSnapshotOpenForSaveListener( event ) func END   if ( (globalData.gpgs) and (gameData.gpgsDataUserPref == "logged in") ) then     globalData.gpgs.snapshots.open({ -- Open the save slot         filename = globalData.snapshotFileName,         create = true, -- Create the snapshot if it's not found         conflictPolicy = "most recently modified",         listener = gpgsSnapshotOpenForSaveListener       })   end -- if ( (globalData.gpgs) and (gameData.gpgsDataUserPref == "logged in") ) then END end -- gpgsUploadData() func END

Except conflictPolicy = “most recently modified”, we are using the same code.

Could this be the reason?

Also I can’t reproduce the crash in my devices.

Maybe Rob can help?

create = true,

May I remove this line?

It’s true by default?

I just fixed the login issue since  isConnected() and isAuthenticated() always gives null pointer exception.

I revisited into snapshot part and its not working. No error is shown but I noticed some discrepancy with the api…  I will upload the code once i get it to work

My code works but there are crashes in some devices and I can’t reproduce them.

Try using this code. After initial testing, it seem to work. I am using 2019.3469

local function gpgsUploadData()   local function gpgsSnapshotOpenForSaveListener( event )     if not event.isError then       local currentSnapshot = globalData.gpgs.snapshots.getSnapshot(event.snapshotId)       currentSnapshot.contents.write(globalData.json.encode( gameData )) -- Write new data as a JSON string into the snapshot       globalData.gpgs.snapshots.save({           snapshotId = event.snapshotId,           description = "Game scores",           image = { filename = "pic.png", baseDir = system.ResourceDirectory },         })     end   end -- gpgsSnapshotOpenForSaveListener( event ) func END   if ( (globalData.gpgs) and (gameData.gpgsDataUserPref == "logged in") ) then     globalData.gpgs.snapshots.open({ -- Open the save slot         filename = globalData.snapshotFileName,         create = true, -- Create the snapshot if it's not found         conflictPolicy = "most recently modified",         listener = gpgsSnapshotOpenForSaveListener       })   end -- if (globalData.gpgs.isAuthenticated()) END end -- gpgsUploadData() func END

mysticeti we are using the same code :slight_smile:

Our only difference is conflictPolicy = “most recently modified”, 

Could this be the reason? I don’t know.

I confirm that the code works but there are random crashes and I can’t reproduce them.

Someone from Corona should step in.

An answer about create = true, would be nice :) 

sorry, I just noticed you were already using this one. 

local currentSnapshot = globalData.gpgs.snapshots.getSnapshot(event.snapshotId)  currentSnapshot.contents.write(globalData.json.encode( gameData )) -- Write new data as a JSON string into the snapshot

and for create the default value is not written, just to be safe I still wrote explicitly. here is the doc link

Try adding the conflict policy = recently modified or according to your wish, since the default option is ‘manual’

I wasn’t asking about conflict policy’s default value.

My question was about  create (= true), parameter of gpgs.snapshots.open function.

for create the default value is not written in the doc, just to be safe I am using true

9k+ views!

Rob? Anyone?

An answer please?

I have also sent an email to Corona about this.

No respond either.

I can’t reproduce the error but with the help of a player I managed to find it!

It’s about create = true,  parameter in gpgs.snapshots.open().

Can I comment it out?

Is it true by default?

I could not reproduce the error as your one. I am using create = true and so far I didn’t get any errors yet. I think you can comment it out since according the docs its optional parameters.