Bug 1476106 - Part 2 - Fix setting of mRuntime when restoring GeckoView from savedInstanceState. r=snorp
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 04 Aug 2018 15:21:40 +0200
changeset 829447 70bfe613b3253974eb3a2d2562739a6fd6d4ed22
parent 829446 1484cdde97b801100ce3b06eb19d510b4f7408ff
child 829448 e936ef6b4b50fc09d0ffb988cb563f4a79d7b34c
push id118781
push userktomlinson@mozilla.com
push dateThu, 16 Aug 2018 02:46:06 +0000
reviewerssnorp
bugs1476106
milestone63.0a1
Bug 1476106 - Part 2 - Fix setting of mRuntime when restoring GeckoView from savedInstanceState. r=snorp The call to mSession.transferFrom(ss.session) in the line above also transfers the window from ss.session into mSession, which means we subsequently won't be able to retrieve a runtime from ss.session any more, thereby defeating the goal of calling mRuntime = ss.session.getRuntime(). This case is encountered e.g. when the containing activity is destroyed and sub- sequently recreated after a configuration change that isn't handled by the app, e.g. screen rotation in the GeckoView example app. MozReview-Commit-ID: 5YGskdLZWqw
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
@@ -387,17 +387,17 @@ public class GeckoView extends FrameLayo
 
         final SavedState ss = (SavedState) state;
         super.onRestoreInstanceState(ss.getSuperState());
 
         if (mSession == null && ss.session != null) {
             setSession(ss.session, ss.session.getRuntime());
         } else if (ss.session != null) {
             mSession.transferFrom(ss.session);
-            mRuntime = ss.session.getRuntime();
+            mRuntime = mSession.getRuntime();
         }
     }
 
     @Override
     public void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
         super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
 
         if (!gainFocus || mIsResettingFocus) {