Commit 8cf13449 authored by Khushal's avatar Khushal Committed by Commit Bot

chrome: Add workaround for samsung dex display with SurfaceControl.

SurfaceControl relies on transaction acks from the framework to
manage pipelining/backpressure for frames sent by display compositor
to SurfaceFlinger. These are not getting dispatched when Chrome is
rendering on an external samsung dex display due to a platform bug
which stalls the rendering pipeline.

This change adds a workaround to disable SurfaceControl while the
Chrome activity is associated with a samsung dex display.

R=boliu@chromium.org

Bug: 1042581
Change-Id: I38c067f6f7f48cf04c192cc59efe95a4c21fa4ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099602
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753118}
parent 81aa83a2
......@@ -342,6 +342,9 @@ void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) {
void CompositorImpl::SetSurface(jobject surface,
bool can_be_used_with_surface_control) {
can_be_used_with_surface_control &=
!root_window_->ApplyDisableSurfaceControlWorkaround();
JNIEnv* env = base::android::AttachCurrentThread();
gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get();
......
......@@ -960,6 +960,11 @@ public class WindowAndroid implements AndroidPermissionDelegate, DisplayAndroidO
window.setAttributes(params);
}
@CalledByNative
private boolean applyDisableSurfaceControlWorkaround() {
return mDisplayAndroid.applyDisableSurfaceControlWorkaround();
}
@SuppressLint("NewApi")
// mSupportedRefreshRateModes should only be set if Display.Mode is available.
@TargetApi(Build.VERSION_CODES.M)
......
......@@ -20,7 +20,7 @@ import java.util.WeakHashMap;
* anywhere, as long as the corresponding WindowAndroids are destroyed. The observers are
* held weakly so to not lead to leaks.
*/
public class DisplayAndroid {
public abstract class DisplayAndroid {
/**
* DisplayAndroidObserver interface for changes to this Display.
*/
......@@ -254,6 +254,8 @@ public class DisplayAndroid {
update(null, null, null, null, null, null, isDisplayServerWideColorGamut, null, null, null);
}
public abstract boolean applyDisableSurfaceControlWorkaround();
/**
* Update the display to the provided parameters. Null values leave the parameter unchanged.
*/
......
......@@ -23,12 +23,16 @@ import java.util.List;
*/
/* package */ class PhysicalDisplayAndroid extends DisplayAndroid {
private static final String TAG = "DisplayAndroid";
private static final String SAMSUNG_DEX_DISPLAY = "Desktop";
// When this object exists, a positive value means that the forced DIP scale is set and
// the zero means it is not. The non existing object (i.e. null reference) means that
// the existence and value of the forced DIP scale has not yet been determined.
private static Float sForcedDIPScale;
// This is a workaround for crbug.com/1042581.
private final boolean mDisableSurfaceControlWorkaround;
private static boolean hasForcedDIPScale() {
if (sForcedDIPScale == null) {
String forcedScaleAsString = CommandLine.getInstance().getSwitchValue(
......@@ -123,6 +127,7 @@ import java.util.List;
/* package */ PhysicalDisplayAndroid(Display display) {
super(display.getDisplayId());
mDisableSurfaceControlWorkaround = display.getName().equals(SAMSUNG_DEX_DISPLAY);
}
@SuppressWarnings("deprecation")
......@@ -162,4 +167,9 @@ import java.util.List;
bitsPerComponent(pixelFormatId), display.getRotation(), isWideColorGamut, null,
display.getRefreshRate(), currentMode, supportedModes);
}
@Override
public boolean applyDisableSurfaceControlWorkaround() {
return mDisableSurfaceControlWorkaround;
}
}
......@@ -57,4 +57,9 @@ public class VirtualDisplayAndroid extends DisplayAndroid {
public void destroy() {
getManager().removeVirtualDisplay(this);
}
@Override
public boolean applyDisableSurfaceControlWorkaround() {
return false;
}
}
......@@ -254,6 +254,12 @@ void WindowAndroid::Force60HzRefreshRateIfNeeded() {
Java_WindowAndroid_setPreferredRefreshRate(env, GetJavaObject(), 60.f);
}
bool WindowAndroid::ApplyDisableSurfaceControlWorkaround() {
JNIEnv* env = AttachCurrentThread();
return Java_WindowAndroid_applyDisableSurfaceControlWorkaround(
env, GetJavaObject());
}
bool WindowAndroid::HasPermission(const std::string& permission) {
JNIEnv* env = AttachCurrentThread();
return Java_WindowAndroid_hasPermission(
......
......@@ -112,6 +112,8 @@ class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid {
void SetForce60HzRefreshRate();
bool ApplyDisableSurfaceControlWorkaround();
class TestHooks {
public:
virtual ~TestHooks() = default;
......
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