Video: Delay query supported encoder configs Query the encoder supported configs may cause too much jank on the GPU main thread at startup, thus change to query the configs 1s later after RenderMediaClient's construction. Bug: 377100050 Bug: 40276507 Change-Id: Ia6eb7ff1c2540975254b9763f67352ce6a4da44d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5992955 Reviewed-by: Dale Curtis <dalecurtis@chromium.org> Commit-Queue: Sida Zhu <zhusida@bytedance.com> Cr-Commit-Position: refs/heads/main@{#1378627}
diff --git a/content/renderer/media/render_media_client.cc b/content/renderer/media/render_media_client.cc index 47a8ac7f..fabe1ca 100644 --- a/content/renderer/media/render_media_client.cc +++ b/content/renderer/media/render_media_client.cc
@@ -167,12 +167,18 @@ // RenderMediaClient is never destructed. base::Unretained(this)), main_task_runner_); - video_encoder_for_supported_profiles_ - ->GetVideoEncodeAcceleratorSupportedProfiles( - base::BindOnce(&RenderMediaClient::OnGetSupportedVideoEncoderConfigs, - // base::Unretained(this) is safe because the - // RenderMediaClient is never destructed. - base::Unretained(this))); + // In case this causing too much jank on the gpu main thread at startup, + // query the configs 1s later. + // + // NOTE: The side effect of this approach is that for non-main threads, + // it is likely have to be blocked for up to a second to complete. + main_task_runner_->PostDelayedTask( + FROM_HERE, + base::BindOnce(&RenderMediaClient::GetSupportedVideoEncoderConfigs, + // base::Unretained(this) is safe because the + // RenderMediaClient is never destructed. + base::Unretained(this)), + base::Milliseconds(1000)); #endif // BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_ENCODE_SUPPORT) } @@ -281,6 +287,21 @@ audio_parameters); } +void RenderMediaClient::GetSupportedVideoEncoderConfigs() { + DCHECK_CALLED_ON_VALID_SEQUENCE(main_thread_sequence_checker_); +#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_ENCODE_SUPPORT) + if (!video_encoder_for_supported_profiles_) { + return; + } + video_encoder_for_supported_profiles_ + ->GetVideoEncodeAcceleratorSupportedProfiles( + base::BindOnce(&RenderMediaClient::OnGetSupportedVideoEncoderConfigs, + // base::Unretained(this) is safe because the + // RenderMediaClient is never destructed. + base::Unretained(this))); +#endif // BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_ENCODE_SUPPORT) +} + void RenderMediaClient::OnInterfaceFactoryDisconnected() { DCHECK_CALLED_ON_VALID_SEQUENCE(main_thread_sequence_checker_); OnAudioDecoderDisconnected();
diff --git a/content/renderer/media/render_media_client.h b/content/renderer/media/render_media_client.h index 7f558288..f5ba9eb 100644 --- a/content/renderer/media/render_media_client.h +++ b/content/renderer/media/render_media_client.h
@@ -50,6 +50,8 @@ RenderMediaClient(); ~RenderMediaClient() override; + void GetSupportedVideoEncoderConfigs(); + void OnInterfaceFactoryDisconnected(); void OnGpuDisconnected(); void OnAudioDecoderDisconnected();