Skip to content

Commit

Permalink
Do not release GeckoDisplay when switching visible window sessions (M…
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and Alexandre Lissy committed Jan 21, 2020
1 parent 58d3470 commit e579436
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;

import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
Expand Down Expand Up @@ -89,6 +90,12 @@ default void onBookmarksShown(WindowWidget aWindow) {}
default void onBookmarksHidden(WindowWidget aWindow) {}
}

@IntDef(value = { SESSION_RELEASE_DISPLAY, SESSION_DO_NOT_RELEASE_DISPLAY})
public @interface OldSessionDisplayAction {}
public static final int SESSION_RELEASE_DISPLAY = 0;
public static final int SESSION_DO_NOT_RELEASE_DISPLAY = 1;


private Surface mSurface;
private int mWidth;
private int mHeight;
Expand Down Expand Up @@ -1030,11 +1037,17 @@ public void draw(Canvas aCanvas) {
}

public void setSession(@NonNull Session aSession) {
setSession(aSession, SESSION_RELEASE_DISPLAY);
}

public void setSession(@NonNull Session aSession, @OldSessionDisplayAction int aDisplayAction) {
if (mSession != aSession) {
Session oldSession = mSession;
if (oldSession != null) {
cleanListeners(oldSession);
oldSession.releaseDisplay();
if (aDisplayAction == SESSION_RELEASE_DISPLAY) {
oldSession.releaseDisplay();
}
}

mSession = aSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,8 @@ public void onTabSelect(Session aTab) {
Session moveTo = targetWindow.getSession();
moveFrom.surfaceDestroyed();
moveTo.surfaceDestroyed();
windowToMove.setSession(moveTo);
targetWindow.setSession(moveFrom);
windowToMove.setSession(moveTo, WindowWidget.SESSION_DO_NOT_RELEASE_DISPLAY);
targetWindow.setSession(moveFrom, WindowWidget.SESSION_DO_NOT_RELEASE_DISPLAY);
SessionStore.get().setActiveSession(targetWindow.getSession());

} else {
Expand Down

0 comments on commit e579436

Please sign in to comment.