playgameservices / cpp-android-basic-samples

Sample games using the Google Play Games C++ SDK
302 stars 133 forks source link

Fix ButtonClicker random crash issue [ the crash happens on 64 bit gpg sdk ] #20

Closed ggfan closed 9 years ago

ggfan commented 9 years ago

1) initialize the jui_helper::JUIWindow::init() before trying to display Toast. GetInstance()->GetContext() needs it inside InitToast() 2)Synchronize UI init with Google Play Games authentication UI with a mutex

ggfan commented 9 years ago

there are 2 scenarios: 1) if the app is not logged in last time, there is no impact -- user will need to log in explicitly; the lock does not matter. 2) if app already logged in last time, when app starts up, gpg will try silent login, and it will try to display pop-up UI. this is the period that we dedicate the UI to gpg so it could display its login UI, not complicate it with UI thread sharing the display with it.

For the above case 1), you could not initDisplay after authentication: I think user need to click/tap a button to start login process For the above case 2), we do not have much control of the gpg because gpg init is inside android_main() loop, it is a head of UI initialization.

It might make sense to force gpg init after UI is initialized, but that would need somewhat re-layout / evaluate overall UI and gpg login code. that would need more experiment. Current fix will make sure we are forcing the thing done in the thread that originated the action [ I think this simplify things ]