Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

GPGS v2 crashes
Started by Aarbron Mar 12 2019 03:13 PM

21 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

Hundreds of crashes.

Used to be fine with version 1.

Any thoughts?

at java.util.Hashtable.put (Hashtable.java:461)
at plugin.gpgs.v2.Utils.gameToHashtable (Utils.java:282)
at plugin.gpgs.v2.Utils.snapshotMetadataToHashtable (Utils.java:312)
at plugin.gpgs.v2.Snapshots$OpenSnapshotOnCompleteListener.onComplete (Snapshots.java:503)
at com.google.android.gms.tasks.zzj.run (Unknown Source:23)
at android.os.Handler.handleCallback (Handler.java:794)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:173)
at android.app.ActivityThread.main (ActivityThread.java:6634)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:822)


[TOPIC: post.html]
#2

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

which corona build are you using?



[TOPIC: post.html]
#3

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

Version 2019.3468



[TOPIC: post.html]
#4

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

can you upload your snapshot and login code implementation



[TOPIC: post.html]
#5

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

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
})


[TOPIC: post.html]
#6

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

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?



[TOPIC: post.html]
#7

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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


[TOPIC: post.html]
#8

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

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?



[TOPIC: post.html]
#9

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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



[TOPIC: post.html]
#10

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

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



[TOPIC: post.html]
#11

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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


[TOPIC: post.html]
#12

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

mysticeti we are using the same code :)

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 = truewould be nice :) 



[TOPIC: post.html]
#13

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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'



[TOPIC: post.html]
#14

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

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

 

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



[TOPIC: post.html]
#15

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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



[TOPIC: post.html]
#16

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

9k+ views!

 

Rob? Anyone?



[TOPIC: post.html]
#17

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

An answer please?

 

I have also sent an email to Corona about this.

No respond either.



[TOPIC: post.html]
#18

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

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?



[TOPIC: post.html]
#19

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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. 



[TOPIC: post.html]
#20

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

@mysticeti

How many daily users do you have?

Could you give me the link of your app?



[TOPIC: post.html]
#21

mysticeti

[GLOBAL: userInfoPane.html]
mysticeti
  • Contributor

  • 143 posts
  • Corona SDK

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



[TOPIC: post.html]
#22

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 221 posts
  • Corona SDK

@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.




[topic_controls]
[/topic_controls]