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