Commit 83063dcc authored by Zhiheng Vincent Li's avatar Zhiheng Vincent Li Committed by Commit Bot

[Chromecast] Fix the flashing page when destroy web content

There is a flashing page when transiting from one cast app to
another cast app or when stopping a cast app. It is caused by redrawing
the webcontent view when destroying the WebContents.

Bug: internal b/79172781 b/79694573

Test: manually tested on Jasper

Change-Id: Ib445301a1f0d2a79cdf5a7dd2652a0666c570f06
Reviewed-on: https://chromium-review.googlesource.com/1132622Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Zhiheng(Vincent) Li <vincentli@google.com>
Cr-Commit-Position: refs/heads/master@{#574794}
parent 7718a4cf
...@@ -66,6 +66,7 @@ public class CastWebContentsFragment extends Fragment { ...@@ -66,6 +66,7 @@ public class CastWebContentsFragment extends Fragment {
mFragmentRootView = inflater.cloneInContext(getContext()) mFragmentRootView = inflater.cloneInContext(getContext())
.inflate(R.layout.cast_web_contents_activity, null); .inflate(R.layout.cast_web_contents_activity, null);
} }
mFragmentRootView.setVisibility(View.VISIBLE);
return mFragmentRootView; return mFragmentRootView;
} }
...@@ -117,10 +118,6 @@ public class CastWebContentsFragment extends Fragment { ...@@ -117,10 +118,6 @@ public class CastWebContentsFragment extends Fragment {
public void onResume() { public void onResume() {
Log.d(TAG, "onResume"); Log.d(TAG, "onResume");
super.onResume(); super.onResume();
// Delayed set mFragmentRootView to visible to avoid activity UI -> one frame of fragment
// background -> cast app rendered UI
mFragmentRootView.setVisibility(View.INVISIBLE);
mFragmentRootView.postDelayed(this ::setToVisible, 150);
mResumedState.set(Unit.unit()); mResumedState.set(Unit.unit());
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.chromecast.shell; package org.chromium.chromecast.shell;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.chromecast.base.ScopeFactory; import org.chromium.chromecast.base.ScopeFactory;
...@@ -46,6 +47,7 @@ class CastWebContentsView { ...@@ -46,6 +47,7 @@ class CastWebContentsView {
contentView.requestFocus(); contentView.requestFocus();
contentViewRenderView.setCurrentWebContents(webContents); contentViewRenderView.setCurrentWebContents(webContents);
return () -> { return () -> {
layout.setForeground(new ColorDrawable(backgroundColor));
layout.removeView(contentView); layout.removeView(contentView);
layout.removeView(contentViewRenderView); layout.removeView(contentViewRenderView);
contentViewRenderView.destroy(); contentViewRenderView.destroy();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment