Commit 3328faef authored by kylechar's avatar kylechar Committed by Commit Bot

Plumb |restart_id| through ExternalBeginFrameSource.

This is used to ensure that ExternalBeginFrameSources have a unique
|source_id| after the GPU process is restarted.

Bug: 871755
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Ic5d6066fa2bcdee3c796f9f56967ffcd51e230f1
Reviewed-on: https://chromium-review.googlesource.com/1165888Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581967}
parent 5974cb31
......@@ -279,8 +279,9 @@ void DelayBasedBeginFrameSource::OnTimerTick() {
// ExternalBeginFrameSource -----------------------------------------------
ExternalBeginFrameSource::ExternalBeginFrameSource(
ExternalBeginFrameSourceClient* client)
: BeginFrameSource(kNotRestartableId), client_(client) {
ExternalBeginFrameSourceClient* client,
uint32_t restart_id)
: BeginFrameSource(restart_id), client_(client) {
DCHECK(client_);
}
......
......@@ -265,7 +265,8 @@ class VIZ_COMMON_EXPORT ExternalBeginFrameSource : public BeginFrameSource {
// Client lifetime must be preserved by owner for the lifetime of the class.
// In order to allow derived classes to implement the client interface, no
// calls to |client| are made during construction / destruction.
explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client);
explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client,
uint32_t restart_id = kNotRestartableId);
~ExternalBeginFrameSource() override;
// BeginFrameSource implementation.
......
......@@ -560,9 +560,10 @@ class MockExternalBeginFrameSourceClient
class ExternalBeginFrameSourceTest : public ::testing::Test {
public:
void SetUp() override {
client_.reset(new MockExternalBeginFrameSourceClient());
source_.reset(new ExternalBeginFrameSource(client_.get()));
obs_.reset(new MockBeginFrameObserver);
client_ = std::make_unique<MockExternalBeginFrameSourceClient>();
source_ = std::make_unique<ExternalBeginFrameSource>(
client_.get(), BeginFrameSource::kNotRestartableId);
obs_ = std::make_unique<MockBeginFrameObserver>();
}
void TearDown() override {
......
......@@ -9,8 +9,9 @@
namespace viz {
ExternalBeginFrameSourceAndroid::ExternalBeginFrameSourceAndroid()
: ExternalBeginFrameSource(this),
ExternalBeginFrameSourceAndroid::ExternalBeginFrameSourceAndroid(
uint32_t restart_id)
: ExternalBeginFrameSource(this, restart_id),
j_object_(Java_ExternalBeginFrameSourceAndroid_Constructor(
base::android::AttachCurrentThread(),
reinterpret_cast<jlong>(this))) {}
......
......@@ -20,7 +20,7 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceAndroid
: public ExternalBeginFrameSource,
public ExternalBeginFrameSourceClient {
public:
ExternalBeginFrameSourceAndroid();
explicit ExternalBeginFrameSourceAndroid(uint32_t restart_id);
~ExternalBeginFrameSourceAndroid() override;
void OnVSync(JNIEnv* env,
......
......@@ -36,7 +36,8 @@ class ExternalBeginFrameSourceAndroidTest : public ::testing::Test,
private:
void InitOnThread() {
begin_frame_source_ = std::make_unique<ExternalBeginFrameSourceAndroid>();
begin_frame_source_ = std::make_unique<ExternalBeginFrameSourceAndroid>(
BeginFrameSource::kNotRestartableId);
}
void AddObserverOnThread(uint32_t frame_count) {
......
......@@ -8,8 +8,9 @@ namespace viz {
ExternalBeginFrameSourceMojo::ExternalBeginFrameSourceMojo(
mojom::ExternalBeginFrameControllerAssociatedRequest controller_request,
mojom::ExternalBeginFrameControllerClientPtr client)
: ExternalBeginFrameSource(this),
mojom::ExternalBeginFrameControllerClientPtr client,
uint32_t restart_id)
: ExternalBeginFrameSource(this, restart_id),
binding_(this, std::move(controller_request)),
client_(std::move(client)) {}
......
......@@ -27,7 +27,8 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceMojo
public:
ExternalBeginFrameSourceMojo(
mojom::ExternalBeginFrameControllerAssociatedRequest controller_request,
mojom::ExternalBeginFrameControllerClientPtr client);
mojom::ExternalBeginFrameControllerClientPtr client,
uint32_t restart_id);
~ExternalBeginFrameSourceMojo() override;
// mojom::ExternalBeginFrameController implementation.
......
......@@ -34,13 +34,17 @@ RootCompositorFrameSinkImpl::Create(
std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source;
ExternalBeginFrameSourceMojo* external_begin_frame_source_mojo = nullptr;
// BeginFrameSource::source_id component that changes on process restart.
uint32_t restart_id = display_provider->GetRestartId();
if (params->external_begin_frame_controller.is_pending() &&
params->external_begin_frame_controller_client) {
auto owned_external_begin_frame_source_mojo =
std::make_unique<ExternalBeginFrameSourceMojo>(
std::move(params->external_begin_frame_controller),
mojom::ExternalBeginFrameControllerClientPtr(
std::move(params->external_begin_frame_controller_client)));
std::move(params->external_begin_frame_controller_client)),
restart_id);
external_begin_frame_source_mojo =
owned_external_begin_frame_source_mojo.get();
external_begin_frame_source =
......@@ -48,12 +52,12 @@ RootCompositorFrameSinkImpl::Create(
} else {
#if defined(OS_ANDROID)
external_begin_frame_source =
std::make_unique<ExternalBeginFrameSourceAndroid>();
std::make_unique<ExternalBeginFrameSourceAndroid>(restart_id);
#else
synthetic_begin_frame_source = std::make_unique<DelayBasedBeginFrameSource>(
std::make_unique<DelayBasedTimeSource>(
base::ThreadTaskRunnerHandle::Get().get()),
display_provider->GetRestartId());
restart_id);
#endif
}
......
......@@ -568,7 +568,8 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
external_begin_frame_source_mojo =
std::make_unique<viz::ExternalBeginFrameSourceMojo>(
std::move(request),
external_begin_frame_controller_client->GetBoundPtr());
external_begin_frame_controller_client->GetBoundPtr(),
viz::BeginFrameSource::kNotRestartableId);
begin_frame_source = external_begin_frame_source_mojo.get();
} else if (disable_frame_rate_limit_) {
synthetic_begin_frame_source =
......
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