From 241fc210555aeadeafdec970d4ca7e372e44c17f Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 4 Jan 2016 10:39:09 -0800 Subject: [PATCH] Don't destory the engine when detaching from the window Reading the Android docs, it sounds like an android.view.View can re-attach to the window after detaching. Previously, we destroyed the engine when we detached from the window. Now we wait for the activity to be destroyed. Hopefully fixes #997 --- .../android/org/domokit/sky/shell/PlatformViewAndroid.java | 3 +-- .../platform/android/org/domokit/sky/shell/SkyActivity.java | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java b/sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java index 149fedf1567..555b05ae282 100644 --- a/sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java +++ b/sky/shell/platform/android/org/domokit/sky/shell/PlatformViewAndroid.java @@ -131,8 +131,7 @@ public class PlatformViewAndroid extends SurfaceView { return mSkyEngine; } - @Override - protected void onDetachedFromWindow() { + void destroy() { getHolder().removeCallback(mSurfaceCallback); nativeDetach(mNativePlatformView); mNativePlatformView = 0; diff --git a/sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java b/sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java index 66f4ee63754..1e04230bb3a 100644 --- a/sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java +++ b/sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java @@ -86,6 +86,9 @@ public class SkyActivity extends Activity { */ @Override protected void onDestroy() { + if (mView != null) { + mView.destroy(); + } // Do we need to shut down Sky too? mTracingController.stop(); super.onDestroy();