Bug 223191 - Attempt to restore highlights after paint to account for newly loaded content.
Summary: Attempt to restore highlights after paint to account for newly loaded content.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-15 10:14 PDT by Megan Gardner
Modified: 2021-03-16 11:44 PDT (History)
2 users (show)

See Also:


Attachments
Patch (4.13 KB, patch)
2021-03-15 10:17 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.64 KB, patch)
2021-03-15 12:13 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.67 KB, patch)
2021-03-15 14:00 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.82 KB, patch)
2021-03-15 17:13 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (5.03 KB, patch)
2021-03-15 19:26 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.82 KB, patch)
2021-03-15 20:32 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.98 KB, patch)
2021-03-15 22:53 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.96 KB, patch)
2021-03-16 08:40 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch for landing (4.95 KB, patch)
2021-03-16 11:12 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2021-03-15 10:14:16 PDT
Attempt to restore highlights after paint to account for newly loaded content.
Comment 1 Megan Gardner 2021-03-15 10:17:41 PDT
Created attachment 423193 [details]
Patch
Comment 2 Tim Horton 2021-03-15 10:28:35 PDT
Comment on attachment 423193 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423193&action=review

> Source/WebCore/page/Page.cpp:1614
> +        if (MonotonicTime() - document.appHighlightStorage().lastRangeSearchTime()  > 1_s) {

Extra space before >

Isn't this going to create the appHighlightStorage if it doesn't exist? Maybe you want to use "IfExists"?

> Source/WebCore/page/Page.cpp:1615
> +            document.eventLoop().queueTask(TaskSource::InternalAsyncTask, [weakDocument = makeWeakPtr(document)] {

Probably should not even bother enqueueing the task if you don't have any remaining outstanding highlights.
Comment 3 Tim Horton 2021-03-15 10:30:03 PDT
Comment on attachment 423193 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423193&action=review

> Source/WebCore/page/Page.cpp:1621
> +                    appHighlightStorage->restoreUnrestoredAppHighlights();

It seems like you're going to queue up a ton of these when you paint quickly, right?? Nothing ever sets m_timeAtLastRangeSearch...
Comment 4 Tim Horton 2021-03-15 10:30:41 PDT
Comment on attachment 423193 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423193&action=review

>> Source/WebCore/page/Page.cpp:1621
>> +                    appHighlightStorage->restoreUnrestoredAppHighlights();
> 
> It seems like you're going to queue up a ton of these when you paint quickly, right?? Nothing ever sets m_timeAtLastRangeSearch...

... until you actually run this, but in the meantime you could have queued up hundreds.
Comment 5 Wenson Hsieh 2021-03-15 10:57:37 PDT
Comment on attachment 423193 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423193&action=review

> Source/WebCore/Modules/highlight/AppHighlightStorage.cpp:268
> +    m_timeAtLastRangeSearch = MonotonicTime();

Did you mean to use `MonotonicTime::now()`? From a glance, it seems like the time offset computed inside the if statement below (`MonotonicTime() - document.appHighlightStorage().lastRangeSearchTime()`) will always be 0_s.

> Source/WebCore/Modules/highlight/AppHighlightStorage.h:59
> +    MonotonicTime lastRangeSearchTime() { return m_timeAtLastRangeSearch; };

Nit - lastRangeSearchTime() should be marked `const`. You can remove the extra ";" at the end of the method definition.
Comment 6 Megan Gardner 2021-03-15 12:13:20 PDT
Created attachment 423214 [details]
Patch
Comment 7 Wenson Hsieh 2021-03-15 12:22:07 PDT
Comment on attachment 423214 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423214&action=review

> Source/WebCore/page/Page.cpp:1615
> +            if (MonotonicTime() - appHighlightStorage->lastRangeSearchTime() > 1_s) {

This looks like it's still subtracting the last range search time from 1/1/1970.
Comment 8 Megan Gardner 2021-03-15 14:00:35 PDT
Created attachment 423234 [details]
Patch
Comment 9 Megan Gardner 2021-03-15 17:13:34 PDT
Created attachment 423266 [details]
Patch
Comment 10 Megan Gardner 2021-03-15 17:14:00 PDT
rdar://74722200
Comment 11 Megan Gardner 2021-03-15 19:26:25 PDT
Created attachment 423283 [details]
Patch
Comment 12 Megan Gardner 2021-03-15 20:32:13 PDT
Created attachment 423291 [details]
Patch
Comment 13 Tim Horton 2021-03-15 20:42:16 PDT
(In reply to Tim Horton from comment #4)
> Comment on attachment 423193 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=423193&action=review
> 
> >> Source/WebCore/page/Page.cpp:1621
> >> +                    appHighlightStorage->restoreUnrestoredAppHighlights();
> > 
> > It seems like you're going to queue up a ton of these when you paint quickly, right?? Nothing ever sets m_timeAtLastRangeSearch...
> 
> ... until you actually run this, but in the meantime you could have queued
> up hundreds.

I don't think you've fixed this.
Comment 14 Megan Gardner 2021-03-15 22:53:07 PDT
Created attachment 423302 [details]
Patch
Comment 15 Tim Horton 2021-03-15 23:05:53 PDT
Comment on attachment 423302 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423302&action=review

> Source/WebCore/page/Page.cpp:1614
> +        if (auto appHighlightStorage = document.appHighlightStorageIfExists()) {

This could just be an early return, since you're in a lambda
Comment 16 Megan Gardner 2021-03-16 08:40:15 PDT
Created attachment 423334 [details]
Patch
Comment 17 Megan Gardner 2021-03-16 11:12:07 PDT
Created attachment 423361 [details]
Patch for landing
Comment 18 EWS 2021-03-16 11:44:45 PDT
Committed r274501: <https://commits.webkit.org/r274501>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423361 [details].