Bug 145230 - Allow overriding the waitForDidUpdateViewState timeout
Summary: Allow overriding the waitForDidUpdateViewState timeout
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-20 16:21 PDT by Tim Horton
Modified: 2016-08-05 14:00 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.31 KB, patch)
2015-05-20 16:22 PDT, Tim Horton
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2015-05-20 16:21:23 PDT
Allow overriding the waitForDidUpdateViewState timeout
Comment 1 Tim Horton 2015-05-20 16:22:21 PDT
Created attachment 253474 [details]
Patch
Comment 2 Darin Adler 2015-05-20 16:42:04 PDT
Comment on attachment 253474 [details]
Patch

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

> Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:407
> +    static std::chrono::milliseconds viewStateUpdateTimeout;
> +    if (viewStateUpdateTimeout == std::chrono::milliseconds::zero()) {
> +        if (id value = [[NSUserDefaults standardUserDefaults] objectForKey:@"WebKit2OverrideViewStateUpdateTimeoutMS"])
> +            viewStateUpdateTimeout = std::chrono::milliseconds([value integerValue]);
> +        else {
>  #if PLATFORM(IOS)
> -    auto viewStateUpdateTimeout = std::chrono::milliseconds(500);
> +            viewStateUpdateTimeout = std::chrono::milliseconds(500);
>  #else
> -    auto viewStateUpdateTimeout = std::chrono::milliseconds(250);
> +            viewStateUpdateTimeout = std::chrono::milliseconds(250);
>  #endif
> +        }
> +    }

We should not use zero as a magic value to mean uninitialized. We should use use a lambda and initialization syntax:

    static std::chrono::milliseconds viewStateUpdateTimeout = [] {
        ... fancy code in here ...
    }();