Bug 212445 - Minimum user interaction time in ResourceLoadStatistics should handle the case of -1
Summary: Minimum user interaction time in ResourceLoadStatistics should handle the cas...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kate Cheney
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-27 16:57 PDT by Kate Cheney
Modified: 2020-05-28 15:35 PDT (History)
3 users (show)

See Also:


Attachments
Patch (35.42 KB, patch)
2020-05-27 17:09 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch for landing (60.39 KB, patch)
2020-05-28 14:48 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kate Cheney 2020-05-27 16:57:20 PDT
Currently in the plist and database, -1 is used to indicate no user interaction. We should handle this in ResourceLoadStatistics when considering minimum user interaction time.
Comment 1 Radar WebKit Bug Importer 2020-05-27 16:57:38 PDT
<rdar://problem/63696470>
Comment 2 Kate Cheney 2020-05-27 17:09:13 PDT
Created attachment 400406 [details]
Patch
Comment 3 Brent Fulgham 2020-05-28 13:28:33 PDT
Comment on attachment 400406 [details]
Patch

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

> Source/WebKit/ChangeLog:10
> +               http/tests/resourceLoadStatistics/operating-dates-all-but-cookies-removed-statistics-with-no-user-interaction.html

Should we have a test for the case where cookies are removed, too?

This seems to be testing the 7-day non-cookie data removal, but what about the 30-day cookie removal?

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2542
> +Optional<WallTime> ResourceLoadStatisticsDatabaseStore::mostRecentUserInteractionTime(DomainData& statistic)

Could this be passed as a const DomainData&?

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2572
> +        if (mostRecentUserInteractionTime)

I think this could just be:

if (auto mostRecentInteractionTime = this->mostRecentInteractionTime(statistic))

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)

How long has that been wrong! Yikes.

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:971
> +Optional<WallTime> ResourceLoadStatisticsMemoryStore::mostRecentUserInteractionTime(ResourceLoadStatistics& statistic)

Seems like this could be "const ResourceLoadStatistics&"

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:1021
> +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)

:-(
Comment 4 John Wilander 2020-05-28 13:28:38 PDT
Comment on attachment 400406 [details]
Patch

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

Looks good! See comment on change log.

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2544
> +    if (statistic.mostRecentUserInteractionTime.secondsSinceEpoch().value() <= 0)

Good that you include 0 here.

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)

😳

> LayoutTests/ChangeLog:7
> +        Reviewed by NOBODY (OOPS!).

Please add a comment on that the case of data deletion are already tested and that these new tests only need to check for the absence of deletion. Also add a comment on which test case(s) started failing once you corrected the issue, if any.
Comment 5 Kate Cheney 2020-05-28 14:41:38 PDT
(In reply to Brent Fulgham from comment #3)
> Comment on attachment 400406 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=400406&action=review
> 
> > Source/WebKit/ChangeLog:10
> > +               http/tests/resourceLoadStatistics/operating-dates-all-but-cookies-removed-statistics-with-no-user-interaction.html
> 
> Should we have a test for the case where cookies are removed, too?
> 
> This seems to be testing the 7-day non-cookie data removal, but what about
> the 30-day cookie removal?
> 

Since the flawed logic only affects non-cookie website data, the 30 day all website data removal case is covered by operating-dates-all-website-data-removed.html and operating-dates-all-website-data-removed-database.html. Good thought though, I can explain this in the ChangeLog.  

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2542
> > +Optional<WallTime> ResourceLoadStatisticsDatabaseStore::mostRecentUserInteractionTime(DomainData& statistic)
> 
> Could this be passed as a const DomainData&?
> 

Yes, good catch. I'll change that.

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2572
> > +        if (mostRecentUserInteractionTime)
> 
> I think this could just be:
> 
> if (auto mostRecentInteractionTime =
> this->mostRecentInteractionTime(statistic))
> 

Nice, will change. 

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> 
> How long has that been wrong! Yikes.

:( 
> 
> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:971
> > +Optional<WallTime> ResourceLoadStatisticsMemoryStore::mostRecentUserInteractionTime(ResourceLoadStatistics& statistic)
> 
> Seems like this could be "const ResourceLoadStatistics&"

Yes, good catch. I'll change that.

> 
> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:1021
> > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> 
> :-(
Comment 6 Kate Cheney 2020-05-28 14:42:36 PDT
(In reply to John Wilander from comment #4)
> Comment on attachment 400406 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=400406&action=review
> 
> Looks good! See comment on change log.
> 
> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2544
> > +    if (statistic.mostRecentUserInteractionTime.secondsSinceEpoch().value() <= 0)
> 
> Good that you include 0 here.
> 
> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> 
> 😳
> 
> > LayoutTests/ChangeLog:7
> > +        Reviewed by NOBODY (OOPS!).
> 
> Please add a comment on that the case of data deletion are already tested
> and that these new tests only need to check for the absence of deletion.
> Also add a comment on which test case(s) started failing once you corrected
> the issue, if any.

Yes, doing this I realized these new tests can replace the old 7-day deletion tests because they cover that test case already. Patch-for-landing will remove the old ones.
Comment 7 Kate Cheney 2020-05-28 14:48:09 PDT
Created attachment 400508 [details]
Patch for landing
Comment 8 Kate Cheney 2020-05-28 14:48:41 PDT
Thanks for the feedback Brent and John!
Comment 9 John Wilander 2020-05-28 15:05:14 PDT
(In reply to katherine_cheney from comment #6)
> (In reply to John Wilander from comment #4)
> > Comment on attachment 400406 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=400406&action=review
> > 
> > Looks good! See comment on change log.
> > 
> > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2544
> > > +    if (statistic.mostRecentUserInteractionTime.secondsSinceEpoch().value() <= 0)
> > 
> > Good that you include 0 here.
> > 
> > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> > > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> > 
> > 😳
> > 
> > > LayoutTests/ChangeLog:7
> > > +        Reviewed by NOBODY (OOPS!).
> > 
> > Please add a comment on that the case of data deletion are already tested
> > and that these new tests only need to check for the absence of deletion.
> > Also add a comment on which test case(s) started failing once you corrected
> > the issue, if any.
> 
> Yes, doing this I realized these new tests can replace the old 7-day
> deletion tests because they cover that test case already. Patch-for-landing
> will remove the old ones.

That was not what I meant. I thought the old tests check the case when data *should* be deleted. But maybe there are *also* previous tests that data was retained?
Comment 10 John Wilander 2020-05-28 15:06:14 PDT
(In reply to John Wilander from comment #9)
> (In reply to katherine_cheney from comment #6)
> > (In reply to John Wilander from comment #4)
> > > Comment on attachment 400406 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=400406&action=review
> > > 
> > > Looks good! See comment on change log.
> > > 
> > > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2544
> > > > +    if (statistic.mostRecentUserInteractionTime.secondsSinceEpoch().value() <= 0)
> > > 
> > > Good that you include 0 here.
> > > 
> > > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> > > > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> > > 
> > > 😳
> > > 
> > > > LayoutTests/ChangeLog:7
> > > > +        Reviewed by NOBODY (OOPS!).
> > > 
> > > Please add a comment on that the case of data deletion are already tested
> > > and that these new tests only need to check for the absence of deletion.
> > > Also add a comment on which test case(s) started failing once you corrected
> > > the issue, if any.
> > 
> > Yes, doing this I realized these new tests can replace the old 7-day
> > deletion tests because they cover that test case already. Patch-for-landing
> > will remove the old ones.
> 
> That was not what I meant. I thought the old tests check the case when data
> *should* be deleted. But maybe there are *also* previous tests that data was
> retained?

I think I see what you're saying. This is just about the non-cookie website data deletion.
Comment 11 Kate Cheney 2020-05-28 15:07:50 PDT
(In reply to John Wilander from comment #10)
> (In reply to John Wilander from comment #9)
> > (In reply to katherine_cheney from comment #6)
> > > (In reply to John Wilander from comment #4)
> > > > Comment on attachment 400406 [details]
> > > > Patch
> > > > 
> > > > View in context:
> > > > https://bugs.webkit.org/attachment.cgi?id=400406&action=review
> > > > 
> > > > Looks good! See comment on change log.
> > > > 
> > > > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2544
> > > > > +    if (statistic.mostRecentUserInteractionTime.secondsSinceEpoch().value() <= 0)
> > > > 
> > > > Good that you include 0 here.
> > > > 
> > > > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> > > > > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> > > > 
> > > > 😳
> > > > 
> > > > > LayoutTests/ChangeLog:7
> > > > > +        Reviewed by NOBODY (OOPS!).
> > > > 
> > > > Please add a comment on that the case of data deletion are already tested
> > > > and that these new tests only need to check for the absence of deletion.
> > > > Also add a comment on which test case(s) started failing once you corrected
> > > > the issue, if any.
> > > 
> > > Yes, doing this I realized these new tests can replace the old 7-day
> > > deletion tests because they cover that test case already. Patch-for-landing
> > > will remove the old ones.
> > 
> > That was not what I meant. I thought the old tests check the case when data
> > *should* be deleted. But maybe there are *also* previous tests that data was
> > retained?
> 
> I think I see what you're saying. This is just about the non-cookie website
> data deletion.

All tests check for proper data deletion for expired statistics. The new 7-day test checks for deletion when including a statistic with -1 as the mostRecentUserInteraction time and with parameters().isRunningTest disabled. This covered the other case, and it didn't make sense to keep the other 7-day data deletion test because it doesn't test actual behavior (because of the parameters().isRunningTest()).
Comment 12 Kate Cheney 2020-05-28 15:08:32 PDT
(In reply to katherine_cheney from comment #11)
> (In reply to John Wilander from comment #10)
> > (In reply to John Wilander from comment #9)
> > > (In reply to katherine_cheney from comment #6)
> > > > (In reply to John Wilander from comment #4)
> > > > > Comment on attachment 400406 [details]
> > > > > Patch
> > > > > 
> > > > > View in context:
> > > > > https://bugs.webkit.org/attachment.cgi?id=400406&action=review
> > > > > 
> > > > > Looks good! See comment on change log.
> > > > > 
> > > > > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2544
> > > > > > +    if (statistic.mostRecentUserInteractionTime.secondsSinceEpoch().value() <= 0)
> > > > > 
> > > > > Good that you include 0 here.
> > > > > 
> > > > > > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2596
> > > > > > +    if (!parameters().isRunningTest && now - oldestUserInteraction < parameters().minimumTimeBetweenDataRecordsRemoval)
> > > > > 
> > > > > 😳
> > > > > 
> > > > > > LayoutTests/ChangeLog:7
> > > > > > +        Reviewed by NOBODY (OOPS!).
> > > > > 
> > > > > Please add a comment on that the case of data deletion are already tested
> > > > > and that these new tests only need to check for the absence of deletion.
> > > > > Also add a comment on which test case(s) started failing once you corrected
> > > > > the issue, if any.
> > > > 
> > > > Yes, doing this I realized these new tests can replace the old 7-day
> > > > deletion tests because they cover that test case already. Patch-for-landing
> > > > will remove the old ones.
> > > 
> > > That was not what I meant. I thought the old tests check the case when data
> > > *should* be deleted. But maybe there are *also* previous tests that data was
> > > retained?
> > 
> > I think I see what you're saying. This is just about the non-cookie website
> > data deletion.
> 
> All tests check for proper data deletion for expired statistics. The new
> 7-day test checks for deletion when including a statistic with -1 as the
> mostRecentUserInteraction time and with parameters().isRunningTest disabled.
> This covered the other case, and it didn't make sense to keep the other
> 7-day data deletion test because it doesn't test actual behavior (because of
> the parameters().isRunningTest()).

In fact, the other test was giving us a false-positive, which is probably worse.
Comment 13 EWS 2020-05-28 15:35:45 PDT
Committed r262265: <https://trac.webkit.org/changeset/262265>

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