Skip to content

Commit

Permalink
Add deadline to Find-in-page idle tasks
Browse files Browse the repository at this point in the history
In some cases such as multiple frame webpages, idle task might never
execute or take a noticably long time to execute. This might lead to
incorrect number of find-in-page result and not highlighting matches
because the scoping is never trigerred. This CL adds a deadline to
scoping idle tasks to ensure all scoping happens in a timely manner.

Bug: 890622,893465
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I8ec998d4c2f42377361c1f7b95c1497a80368ef6
Reviewed-on: https://chromium-review.googlesource.com/c/1270196
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599562}
  • Loading branch information
rakina authored and Commit Bot committed Oct 15, 2018
1 parent a643a13 commit 0df2607
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
namespace blink {

namespace {
const int kScopingTimeoutMS = 100;
constexpr TimeDelta kTextFinderTestTimeout = TimeDelta::FromSeconds(10);
}

Expand Down Expand Up @@ -113,9 +114,15 @@ class TextFinder::IdleScopeStringMatchesCallback
identifier_(identifier),
search_text_(search_text),
options_(options.Clone()) {
// We need to add deadline because some webpages might have frames
// that are always busy, resulting in bad experience in find-in-page
// because the scoping tasks are not run.
// See crbug.com/893465.
IdleRequestOptions request_options;
request_options.setTimeout(kScopingTimeoutMS);
callback_handle_ =
text_finder->GetFrame()->GetDocument()->RequestIdleCallback(
this, IdleRequestOptions());
this, request_options);
}

void invoke(IdleDeadline* deadline) override {
Expand Down

0 comments on commit 0df2607

Please sign in to comment.