New issue
Advanced search Search tips

Issue 900679 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 13
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Potential jank caused by MediaEngagementService::RecordStoredScoresToHistogram() at startup

Project Member Reported by ssid@chromium.org, Oct 31

Issue description

We collected slow reports from users facing janks and found that the function mentioned above is taking too much time on the main thread, potentially causing janks.
The issue can be found in reports:

Go to crash/ReportID to view the traces.

https://crash.corp.google.com/browse?q=reportid=%271559f17e478c0eaf%27#6 - 2sec
https://crash.corp.google.com/browse?q=reportid=%27aab97be18380508c%27#6 - 1.5s
https://crash.corp.google.com/browse?q=reportid=%27200d8119f253c87c%27#6 - 1.2s

There is a very long event just in startup with this args:
src_file	"../../chrome/browser/media/media_engagement_service.cc"
src_func	"MediaEngagementService"


Some probable suspects from stack samples:

	
base::Value::Clone() const
base::Value::Value(base::flat_map<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> >, std::__ndk1::less<void> > const&)
base::Value::Clone() const
MediaEngagementService::GetAllStoredScores() const
MediaEngagementService::RecordStoredScoresToHistogram()
base::(anonymous namespace)::RunIfNotCanceled(base::CancellationFlag const*, base::OnceCallback<void ()>)
base::internal::Invoker<base::internal::BindState<void (*)(base::CancellationFlag const*, base::OnceCallback<void ()>), base::CancellationFlag*, base::OnceCallback<void ()> >, void ()>::RunOnce(base::internal::BindStateBase*)
base::(anonymous namespace)::PostTaskAndReplyRelay::RunTaskAndPostReply(base::(anonymous namespace)::PostTaskAndReplyRelay)
void base::internal::FunctorTraits<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), void>::Invoke<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay>(void (*&&)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay&&)
base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)
base::MessageLoop::RunTask(base::PendingTask*)
base::MessageLoop::DoWork()
base::MessagePumpForUI::OnNonDelayedLooperCallback()
base::(anonymous namespace)::NonDelayedLooperCallback(int, int, void*)



ContentSettingPatternSource::ContentSettingPatternSource(ContentSettingPatternSource const&)
std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >::__swap_out_circular_buffer(std::__ndk1::__split_buffer<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource>&>&)
void std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >::emplace_back<ContentSettingsPattern const&, ContentSettingsPattern const&, base::Value, char const* const&, bool&>(ContentSettingsPattern const&, ContentSettingsPattern const&, base::Value&&, char const* const&, bool&)
HostContentSettingsMap::AddSettingsForOneType(content_settings::ProviderInterface const*, HostContentSettingsMap::ProviderType, ContentSettingsType, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >*, bool) const
HostContentSettingsMap::GetSettingsForOneType(ContentSettingsType, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >*) const
MediaEngagementService::GetAllStoredScores() const
MediaEngagementService::RecordStoredScoresToHistogram()
base::(anonymous namespace)::RunIfNotCanceled(base::CancellationFlag const*, base::OnceCallback<void ()>)
base::internal::Invoker<base::internal::BindState<void (*)(base::CancellationFlag const*, base::OnceCallback<void ()>), base::CancellationFlag*, base::OnceCallback<void ()> >, void ()>::RunOnce(base::internal::BindStateBase*)
base::(anonymous namespace)::PostTaskAndReplyRelay::RunTaskAndPostReply(base::(anonymous namespace)::PostTaskAndReplyRelay)
void base::internal::FunctorTraits<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), void>::Invoke<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay>(void (*&&)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay&&)
base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)
base::MessageLoop::RunTask(base::PendingTask*)
base::MessageLoop::DoWork()
base::MessagePumpForUI::OnNonDelayedLooperCallback()
base::(anonymous namespace)::NonDelayedLooperCallback(int, int, void*)



operator delete(void*)
std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >::~basic_string()
std::__ndk1::__vector_base<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> > >, std::__ndk1::allocator<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> > > > >::__destruct_at_end(std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> > >*)
std::__ndk1::__vector_base<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> > >, std::__ndk1::allocator<std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> > > > >::~__vector_base()
base::Value::~Value()
ContentSettingPatternSource::~ContentSettingPatternSource()
std::__ndk1::__vector_base<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >::__destruct_at_end(ContentSettingPatternSource*)
std::__ndk1::__vector_base<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >::~__vector_base()
MediaEngagementService::GetAllStoredScores() const
MediaEngagementService::RecordStoredScoresToHistogram()
base::(anonymous namespace)::RunIfNotCanceled(base::CancellationFlag const*, base::OnceCallback<void ()>)
base::internal::Invoker<base::internal::BindState<void (*)(base::CancellationFlag const*, base::OnceCallback<void ()>), base::CancellationFlag*, base::OnceCallback<void ()> >, void ()>::RunOnce(base::internal::BindStateBase*)
base::(anonymous namespace)::PostTaskAndReplyRelay::RunTaskAndPostReply(base::(anonymous namespace)::PostTaskAndReplyRelay)
void base::internal::FunctorTraits<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), void>::Invoke<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay>(void (*&&)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay&&)
base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)
base::MessageLoop::RunTask(base::PendingTask*)
base::MessageLoop::DoWork()
base::MessagePumpForUI::OnNonDelayedLooperCallback()
base::(anonymous namespace)::NonDelayedLooperCallback(int, int, void*)



base::Value::Value(base::flat_map<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, std::__ndk1::unique_ptr<base::Value, std::__ndk1::default_delete<base::Value> >, std::__ndk1::less<void> > const&)
base::Value::Clone() const
ContentSettingPatternSource::operator=(ContentSettingPatternSource const&)
ContentSettingPatternSource::ContentSettingPatternSource(ContentSettingPatternSource const&)
std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >::__swap_out_circular_buffer(std::__ndk1::__split_buffer<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource>&>&)
void std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >::emplace_back<ContentSettingsPattern const&, ContentSettingsPattern const&, base::Value, char const* const&, bool&>(ContentSettingsPattern const&&&, ContentSettingsPattern const&&&, base::Value&&, char const* const&&&, bool&&&)
HostContentSettingsMap::AddSettingsForOneType(content_settings::ProviderInterface const*, HostContentSettingsMap::ProviderType, ContentSettingsType, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >*, bool) const
HostContentSettingsMap::GetSettingsForOneType(ContentSettingsType, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::vector<ContentSettingPatternSource, std::__ndk1::allocator<ContentSettingPatternSource> >*) const
MediaEngagementService::GetAllStoredScores() const
MediaEngagementService::RecordStoredScoresToHistogram()
base::(anonymous namespace)::RunIfNotCanceled(base::CancellationFlag const*, base::OnceCallback<void ()>)
base::internal::Invoker<base::internal::BindState<void (*)(base::CancellationFlag const*, base::OnceCallback<void ()>), base::CancellationFlag*, base::OnceCallback<void ()> >, void ()>::RunOnce(base::internal::BindStateBase*)
base::(anonymous namespace)::PostTaskAndReplyRelay::RunTaskAndPostReply(base::(anonymous namespace)::PostTaskAndReplyRelay)
void base::internal::FunctorTraits<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), void>::Invoke<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay>(void (*&&)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay&&)
base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)
base::MessageLoop::RunTask(base::PendingTask*)
base::MessageLoop::DoWork()
base::MessagePumpForUI::OnNonDelayedLooperCallback()
base::(anonymous namespace)::NonDelayedLooperCallback(int, int, void*)



memcmp
std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >::compare(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >) const
base::FilePath::operator<(base::FilePath const&) const
MediaEngagementService::GetAllStoredScores() const
MediaEngagementService::RecordStoredScoresToHistogram()
base::internal::Invoker<base::internal::BindState<void (android_webview::AwBrowserContext::*)(), base::internal::UnretainedWrapper<android_webview::AwBrowserContext> >, void ()>::Run(base::internal::BindStateBase*)
base::(anonymous namespace)::RunIfNotCanceled(base::CancellationFlag const*, base::OnceCallback<void ()>)
base::internal::Invoker<base::internal::BindState<void (*)(base::CancellationFlag const*, base::OnceCallback<void ()>), base::CancellationFlag*, base::OnceCallback<void ()> >, void ()>::RunOnce(base::internal::BindStateBase*)
base::(anonymous namespace)::PostTaskAndReplyRelay::RunTaskAndPostReply(base::(anonymous namespace)::PostTaskAndReplyRelay)
void base::internal::FunctorTraits<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), void>::Invoke<void (*)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay>(void (*&&)(base::(anonymous namespace)::PostTaskAndReplyRelay), base::(anonymous namespace)::PostTaskAndReplyRelay&&)
base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)
base::MessageLoop::RunTask(base::PendingTask*)
base::MessageLoop::DoWork()
base::MessagePumpForUI::OnNonDelayedLooperCallback()
base::(anonymous namespace)::NonDelayedLooperCallback(int, int, void*)
 
Cc: etienneb@chromium.org
Components: Blink>Media
Owner: beccahughes@chromium.org
Roughly 1% of users face more than 100ms long Record() event at startup on Dev channel.

Some things to try:

1. Moving this work off browser UI thread. Reading file / long settings parsing / recording too many metrics on browser UI thread may cause janks. Try moving as much work as possible to background thread.

2. Consider using content::BrowserThread::PostAfterStartupTask() which will post this task after startup instead of in startup. That being said this only moves problem to later and will still cause janks on UI thread. But at least it won't affect page load time *always*.

Android system kills browser process if it has 5sec no response at startup usually. The janks from the reports show 2s long tasks which are dangerous.
Status: Fixed (was: Untriaged)
Project Member

Comment 3 by bugdroid1@chromium.org, Nov 13

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a78d20743acc9e2777aa375d4dee2d8e970317bc

commit a78d20743acc9e2777aa375d4dee2d8e970317bc
Author: Becca Hughes <beccahughes@chromium.org>
Date: Tue Nov 13 21:47:44 2018

[Media Engagement] Remove histogram

Remove the ScoreAtStartup histogram as it was causing
jank and we were not using it.

BUG= 900679 

Change-Id: I004743c48425c9bb3fbbed67004c7616ef290cf9
Reviewed-on: https://chromium-review.googlesource.com/c/1330211
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: Brian White <bcwhite@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607751}
[modify] https://crrev.com/a78d20743acc9e2777aa375d4dee2d8e970317bc/chrome/browser/media/media_engagement_service.cc
[modify] https://crrev.com/a78d20743acc9e2777aa375d4dee2d8e970317bc/chrome/browser/media/media_engagement_service.h
[modify] https://crrev.com/a78d20743acc9e2777aa375d4dee2d8e970317bc/chrome/browser/media/media_engagement_service_unittest.cc
[modify] https://crrev.com/a78d20743acc9e2777aa375d4dee2d8e970317bc/tools/metrics/histograms/histograms.xml

Sign in to add a comment