зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1120441 - Don't try to show tab-history panel if app has been shutdown r=sebastian
Showing the tab history panel involves a gecko call to retrieve tab history. This can be slow, meaning we have no idea what state the app will be in when the tab history data is returned. Thus we need to protect the code that shows the tab history fragment against a number of scenarios to avoid crashes in those cases where the app might be shutting down: 1. If onSaveInstanceState() has been called (which might happen before or after onPause(), and might be linked to app shutdown - but the docs don't appear to give any guarantees), fragment transactions cannot be performed. We protect against this by accepting loss of state in fragment transactions. 2. If the Activity has been completely destroyed, trying to perform a fragment transaction will likewise fail. We protect against this by not even trying to perform the transaction if we definitively know that the Activity is being shut down (ie isFinishing()). In both of these cases, we simply must accept that we're potentially losing UI state: i.e. a user could request the tab history panel via long-back-press, followed by exiting the app; we now end up never ever showing the panel. This scenario doesn't seem like a major loss - and fixing this issue properly would require significant investment (i.e. we would need to either cache tab history on frontend side, or cache the tab-history panel request - and it's not clear users will still care about seeing the panel the next time they open firefox). MozReview-Commit-ID: JsAK1By8yqn --HG-- extra : rebase_source : 9a3b64d2829a969e4de2775c2714874aa8708031
This commit is contained in:
Родитель
9e5942e772
Коммит
68b1cebd29
|
@ -648,9 +648,20 @@ public class BrowserApp extends GeckoApp
|
|||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (BrowserApp.this.isFinishing()) {
|
||||
// TabHistoryController is rather slow - and involves calling into Gecko
|
||||
// to retrieve tab history. That means there can be a significant
|
||||
// delay between the back-button long-press, and onShowHistory()
|
||||
// being called. Hence we need to guard against the Activity being
|
||||
// shut down (in which case trying to perform UI changes, such as showing
|
||||
// fragments below, will crash).
|
||||
return;
|
||||
}
|
||||
|
||||
final TabHistoryFragment fragment = TabHistoryFragment.newInstance(historyPageList, toIndex);
|
||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
GeckoAppShell.vibrateOnHapticFeedbackEnabled(getResources().getIntArray(R.array.long_press_vibrate_msec));
|
||||
if (BrowserApp.this.isForegrounded())
|
||||
fragment.show(R.id.tab_history_panel, fragmentManager.beginTransaction(), TAB_HISTORY_FRAGMENT_TAG);
|
||||
}
|
||||
});
|
||||
|
@ -1061,6 +1072,7 @@ public class BrowserApp extends GeckoApp
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (mIsAbortingAppLaunch) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,10 @@ public class TabHistoryFragment extends Fragment implements OnItemClickListener,
|
|||
dismissed = false;
|
||||
transaction.add(containerViewId, this, tag);
|
||||
transaction.addToBackStack(tag);
|
||||
backStackId = transaction.commit();
|
||||
// Populating the tab history requires a gecko call (which can be slow) - therefore the app
|
||||
// state by the time we try to show this fragment is unknown, and we could be in the
|
||||
// middle of shutting down:
|
||||
backStackId = transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
// Pop the fragment from backstack if it exists.
|
||||
|
|
Загрузка…
Ссылка в новой задаче