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() { ...@@ -279,8 +279,9 @@ void DelayBasedBeginFrameSource::OnTimerTick() {
// ExternalBeginFrameSource ----------------------------------------------- // ExternalBeginFrameSource -----------------------------------------------
ExternalBeginFrameSource::ExternalBeginFrameSource( ExternalBeginFrameSource::ExternalBeginFrameSource(
ExternalBeginFrameSourceClient* client) ExternalBeginFrameSourceClient* client,
: BeginFrameSource(kNotRestartableId), client_(client) { uint32_t restart_id)
: BeginFrameSource(restart_id), client_(client) {
DCHECK(client_); DCHECK(client_);
} }
......
...@@ -265,7 +265,8 @@ class VIZ_COMMON_EXPORT ExternalBeginFrameSource : public BeginFrameSource { ...@@ -265,7 +265,8 @@ class VIZ_COMMON_EXPORT ExternalBeginFrameSource : public BeginFrameSource {
// Client lifetime must be preserved by owner for the lifetime of the class. // 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 // In order to allow derived classes to implement the client interface, no
// calls to |client| are made during construction / destruction. // calls to |client| are made during construction / destruction.
explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client); explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client,
uint32_t restart_id = kNotRestartableId);
~ExternalBeginFrameSource() override; ~ExternalBeginFrameSource() override;
// BeginFrameSource implementation. // BeginFrameSource implementation.
......
...@@ -560,9 +560,10 @@ class MockExternalBeginFrameSourceClient ...@@ -560,9 +560,10 @@ class MockExternalBeginFrameSourceClient
class ExternalBeginFrameSourceTest : public ::testing::Test { class ExternalBeginFrameSourceTest : public ::testing::Test {
public: public:
void SetUp() override { void SetUp() override {
client_.reset(new MockExternalBeginFrameSourceClient()); client_ = std::make_unique<MockExternalBeginFrameSourceClient>();
source_.reset(new ExternalBeginFrameSource(client_.get())); source_ = std::make_unique<ExternalBeginFrameSource>(
obs_.reset(new MockBeginFrameObserver); client_.get(), BeginFrameSource::kNotRestartableId);
obs_ = std::make_unique<MockBeginFrameObserver>();
} }
void TearDown() override { void TearDown() override {
......
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
namespace viz { namespace viz {
ExternalBeginFrameSourceAndroid::ExternalBeginFrameSourceAndroid() ExternalBeginFrameSourceAndroid::ExternalBeginFrameSourceAndroid(
: ExternalBeginFrameSource(this), uint32_t restart_id)
: ExternalBeginFrameSource(this, restart_id),
j_object_(Java_ExternalBeginFrameSourceAndroid_Constructor( j_object_(Java_ExternalBeginFrameSourceAndroid_Constructor(
base::android::AttachCurrentThread(), base::android::AttachCurrentThread(),
reinterpret_cast<jlong>(this))) {} reinterpret_cast<jlong>(this))) {}
......
...@@ -20,7 +20,7 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceAndroid ...@@ -20,7 +20,7 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceAndroid
: public ExternalBeginFrameSource, : public ExternalBeginFrameSource,
public ExternalBeginFrameSourceClient { public ExternalBeginFrameSourceClient {
public: public:
ExternalBeginFrameSourceAndroid(); explicit ExternalBeginFrameSourceAndroid(uint32_t restart_id);
~ExternalBeginFrameSourceAndroid() override; ~ExternalBeginFrameSourceAndroid() override;
void OnVSync(JNIEnv* env, void OnVSync(JNIEnv* env,
......
...@@ -36,7 +36,8 @@ class ExternalBeginFrameSourceAndroidTest : public ::testing::Test, ...@@ -36,7 +36,8 @@ class ExternalBeginFrameSourceAndroidTest : public ::testing::Test,
private: private:
void InitOnThread() { void InitOnThread() {
begin_frame_source_ = std::make_unique<ExternalBeginFrameSourceAndroid>(); begin_frame_source_ = std::make_unique<ExternalBeginFrameSourceAndroid>(
BeginFrameSource::kNotRestartableId);
} }
void AddObserverOnThread(uint32_t frame_count) { void AddObserverOnThread(uint32_t frame_count) {
......
...@@ -8,8 +8,9 @@ namespace viz { ...@@ -8,8 +8,9 @@ namespace viz {
ExternalBeginFrameSourceMojo::ExternalBeginFrameSourceMojo( ExternalBeginFrameSourceMojo::ExternalBeginFrameSourceMojo(
mojom::ExternalBeginFrameControllerAssociatedRequest controller_request, mojom::ExternalBeginFrameControllerAssociatedRequest controller_request,
mojom::ExternalBeginFrameControllerClientPtr client) mojom::ExternalBeginFrameControllerClientPtr client,
: ExternalBeginFrameSource(this), uint32_t restart_id)
: ExternalBeginFrameSource(this, restart_id),
binding_(this, std::move(controller_request)), binding_(this, std::move(controller_request)),
client_(std::move(client)) {} client_(std::move(client)) {}
......
...@@ -27,7 +27,8 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceMojo ...@@ -27,7 +27,8 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceMojo
public: public:
ExternalBeginFrameSourceMojo( ExternalBeginFrameSourceMojo(
mojom::ExternalBeginFrameControllerAssociatedRequest controller_request, mojom::ExternalBeginFrameControllerAssociatedRequest controller_request,
mojom::ExternalBeginFrameControllerClientPtr client); mojom::ExternalBeginFrameControllerClientPtr client,
uint32_t restart_id);
~ExternalBeginFrameSourceMojo() override; ~ExternalBeginFrameSourceMojo() override;
// mojom::ExternalBeginFrameController implementation. // mojom::ExternalBeginFrameController implementation.
......
...@@ -34,13 +34,17 @@ RootCompositorFrameSinkImpl::Create( ...@@ -34,13 +34,17 @@ RootCompositorFrameSinkImpl::Create(
std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source; std::unique_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source;
ExternalBeginFrameSourceMojo* external_begin_frame_source_mojo = nullptr; 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() && if (params->external_begin_frame_controller.is_pending() &&
params->external_begin_frame_controller_client) { params->external_begin_frame_controller_client) {
auto owned_external_begin_frame_source_mojo = auto owned_external_begin_frame_source_mojo =
std::make_unique<ExternalBeginFrameSourceMojo>( std::make_unique<ExternalBeginFrameSourceMojo>(
std::move(params->external_begin_frame_controller), std::move(params->external_begin_frame_controller),
mojom::ExternalBeginFrameControllerClientPtr( 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 = external_begin_frame_source_mojo =
owned_external_begin_frame_source_mojo.get(); owned_external_begin_frame_source_mojo.get();
external_begin_frame_source = external_begin_frame_source =
...@@ -48,12 +52,12 @@ RootCompositorFrameSinkImpl::Create( ...@@ -48,12 +52,12 @@ RootCompositorFrameSinkImpl::Create(
} else { } else {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
external_begin_frame_source = external_begin_frame_source =
std::make_unique<ExternalBeginFrameSourceAndroid>(); std::make_unique<ExternalBeginFrameSourceAndroid>(restart_id);
#else #else
synthetic_begin_frame_source = std::make_unique<DelayBasedBeginFrameSource>( synthetic_begin_frame_source = std::make_unique<DelayBasedBeginFrameSource>(
std::make_unique<DelayBasedTimeSource>( std::make_unique<DelayBasedTimeSource>(
base::ThreadTaskRunnerHandle::Get().get()), base::ThreadTaskRunnerHandle::Get().get()),
display_provider->GetRestartId()); restart_id);
#endif #endif
} }
......
...@@ -568,7 +568,8 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( ...@@ -568,7 +568,8 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
external_begin_frame_source_mojo = external_begin_frame_source_mojo =
std::make_unique<viz::ExternalBeginFrameSourceMojo>( std::make_unique<viz::ExternalBeginFrameSourceMojo>(
std::move(request), 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(); begin_frame_source = external_begin_frame_source_mojo.get();
} else if (disable_frame_rate_limit_) { } else if (disable_frame_rate_limit_) {
synthetic_begin_frame_source = 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