question

Keith Berman avatar image
Keith Berman asked

Exception after submitScore when showing Leaderboard Toast

I've been noticing recently that on certain instances I get exceptions during the AmazonGamesClient.release call. What I am doing is calling submitScore at the end of a game in a separate thread, at the same time going to a separate Activity. I can disable the popups and everything is fine, and I could implement my own toasts, but I'd hope someone else has a better solution Below is the exception I receive java.lang.RuntimeException: Unable to pause activity {com.**.**/com.**.**.view.GameActivity}: java.lang.IllegalStateException: Calling with view com.amazon.ags.html5.overlay.toasts.ClickableWebViewToast@4188bea0 but the ViewAncestor is attached to null at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2797) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2752) at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2730) at android.app.ActivityThread.access$800(ActivityThread.java:127) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1188) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4558) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalStateException: Calling with view com.amazon.ags.html5.overlay.toasts.ClickableWebViewToast@4188bea0 but the ViewAncestor is attached to null at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:335) at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:151) at com.amazon.ags.html5.overlay.toasts.ClickableToastImpl.dismiss(ClickableToastImpl.java:290) at com.amazon.ags.html5.overlay.toasts.ClickableToastFactoryImpl.dismissCurrentToast(ClickableToastFactoryImpl.java:166) at com.amazon.ags.html5.factory.ServiceFactory.onPause(ServiceFactory.java:403) at com.amazon.ags.api.AmazonGamesClient.release_internal(AmazonGamesClient.java:535) at com.amazon.ags.api.AmazonGamesClient.release(AmazonGamesClient.java:516) at com.**.utilities.AmazonGameCircle.release(AmazonGameCircle.java:107) at com.**.**.view.AchievementActivity.onPause(AchievementActivity.java:67) at com.**.**.view.GameActivity.onPause(GameActivity.java:139) at android.app.Activity.performPause(Activity.java:4745) at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1195) at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2784)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Nick Gardner avatar image
Nick Gardner answered
Hi, It sounds like there's a race condition that might be doing on here due to the pausing of the activity when leaving it, which is probably causing issues with the thread that is submitting the scores. You might be able to hold the activity for a short period of time for the score submission to return before going to the next activity, or retool the multi-tasking flow so the gamecircle method is in a more persistent thread. Thanks, Nick
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.