Bug 230847

Summary: REGRESSION (r283102): [ MacOS Debug ] TestWebKitAPI.WebKit2.CaptureIndicatorDelay is failing
Product: WebKit Reporter: ayumi_kojima
Component: JavaScriptCoreAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: saam, webkit-bot-watchers-bugzilla, webkit-bug-importer, youennf, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Mac (Intel)   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=229223
Attachments:
Description Flags
patch
none
Patch
none
Patch
none
Patch none

Description ayumi_kojima 2021-09-27 09:39:13 PDT
TestWebKitAPI.WebKit2.CaptureIndicatorDelay 

Is failing on macOS Debug.

History: https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.WebKit2.CaptureIndicatorDelay

TestWebKitAPI.WebKit2.CaptureIndicatorDelay
        2021-09-27 08:06:21.207 TestWebKitAPI[35291:3521683] Encountered error: Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=22, WKJavaScriptExceptionMessage=TypeError: null is not an object (evaluating 'stream.getTracks'), WKJavaScriptExceptionColumnNumber=23, WKJavaScriptExceptionSourceURL=file:///Volumes/Data/worker/bigsur-debug-tests-wk2/build/WebKitBuild/Debug/TestWebKitAPI.resources/getUserMedia.html, NSLocalizedDescription=A JavaScript exception occurred} while evaluating script: stop()
        2021-09-27 08:06:32.214 TestWebKitAPI[35291:3521683] Expected state _WKMediaCaptureStateDeprecatedNone, but after 10 seconds state is _WKMediaCaptureStateDeprecatedActiveCamera 
        LEAK: 1 WebProcessPool
        LEAK: 1 WebPageProxy
        
        /Volumes/Data/worker/bigsur-debug/build/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:211
        Value of: !error
          Actual: false
        Expected: true
        
        
        /Volumes/Data/worker/bigsur-debug/build/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:405
        Value of: waitUntilCaptureState(webView.get(), _WKMediaCaptureStateDeprecatedNone)
          Actual: false
        Expected: true
Comment 1 Radar WebKit Bug Importer 2021-09-27 09:40:11 PDT
<rdar://problem/83577251>
Comment 2 ayumi_kojima 2021-09-27 09:43:04 PDT
According to the history, the test started failing at https://trac.webkit.org/changeset/283102/webkit
Comment 3 Alexey Proskuryakov 2021-09-27 12:50:31 PDT
This change was reverted again.

*** This bug has been marked as a duplicate of bug 230854 ***
Comment 4 Saam Barati 2021-09-27 13:25:41 PDT
Relanding unlinked baseline. Need to figure this out
Comment 5 Saam Barati 2021-09-27 17:44:29 PDT
I think my patch just perturbed a pre-existing race.
Comment 6 Saam Barati 2021-09-27 17:49:37 PDT
Created attachment 439421 [details]
patch
Comment 7 youenn fablet 2021-09-28 01:05:47 PDT
Comment on attachment 439421 [details]
patch

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

> Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:398
> +    [webView stringByEvaluatingJavaScript:@"setTimeout(stop, 0)"];

I think this might still be racy, at least in theory.
Let's make it bullet proof by waiting for getUserMedia promise resolution to actually call stop.
Comment 8 youenn fablet 2021-09-28 01:08:13 PDT
Created attachment 439439 [details]
Patch
Comment 9 youenn fablet 2021-09-28 05:54:38 PDT
Created attachment 439463 [details]
Patch
Comment 10 youenn fablet 2021-09-28 06:39:31 PDT
Created attachment 439470 [details]
Patch
Comment 11 EWS 2021-09-28 09:17:32 PDT
Committed r283172 (242220@main): <https://commits.webkit.org/242220@main>

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