Bug 216371

Summary: Some WebAudio tests give different output on different machines
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web AudioAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, calvaris, eric.carlson, ews-watchlist, ggaren, glenn, jer.noble, philipj, pnormand, sergio, vjaquez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 216425    
Bug Blocks: 212611    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2020-09-10 09:50:45 PDT
Some WebAudio tests give different output on different machines, because they rely on the hardware's preferred sample rate.
Comment 1 Chris Dumez 2020-09-10 09:56:11 PDT
Created attachment 408453 [details]
Patch
Comment 2 Alex Christensen 2020-09-10 10:10:03 PDT
Comment on attachment 408453 [details]
Patch

Could you pass it through the WebPageCreationParameters instead of making new bundle SPI?
Comment 3 Chris Dumez 2020-09-10 10:13:32 PDT
(In reply to Alex Christensen from comment #2)
> Comment on attachment 408453 [details]
> Patch
> 
> Could you pass it through the WebPageCreationParameters instead of making
> new bundle SPI?

I was trying to reduce the amount of plumbing necessary. Also, this hardwareSampleRate() is a global static so I did not really want this to be per page.
Comment 4 Alex Christensen 2020-09-10 10:17:39 PDT
Comment on attachment 408453 [details]
Patch

Why do you pass a WKBundleRef then?
I think we should not be expanding the bundle SPI, even for testing, if we can get away with not expanding it.  In this case we can.
Comment 5 Chris Dumez 2020-09-10 10:23:47 PDT
(In reply to Alex Christensen from comment #4)
> Comment on attachment 408453 [details]
> Patch
> 
> Why do you pass a WKBundleRef then?

> I think we should not be expanding the bundle SPI, even for testing, if we
> can get away with not expanding it.  In this case we can.

Can you clarify your proposal? You want the SPI to be on the WKWebView even though the sample rate is process-wide? Also, how about when the view swaps process? I would need to add logic to forward the sample rate to the new process?

Doing it like you suggest adds more code and complexity.
Comment 6 Alex Christensen 2020-09-10 10:41:35 PDT
Comment on attachment 408453 [details]
Patch

I think we should make a WKWebViewConfigurationPrivateForTesting.h like we have WKWebViewPrivateForTesting.h, add an override there, then copy it to an Optional on WebPageCreationParameters, then in the WebPage constructor if it's not nullopt we set it globally in that process.  When we process swap, a new WebPageCreationParameters is already sent to the new process.  It's not perfect, but it's good enough for test-only SPI.
If you really think that's not a good direction and would prefer increasing our dependence on the bundle, r=me
Comment 7 Chris Dumez 2020-09-10 11:20:41 PDT
Committed r266842: <https://trac.webkit.org/changeset/266842>
Comment 8 Radar WebKit Bug Importer 2020-09-10 11:21:18 PDT
<rdar://problem/68653909>
Comment 9 Alex Christensen 2020-09-10 11:29:07 PDT
I think the best solution would have been to modify the web platform tests to print out a deterministic output.
Comment 10 Chris Dumez 2020-09-10 15:57:56 PDT
Reverted r266842 and r266883 for reason:

Causes some assertions to be hit in debug builds

Committed r266895: <https://trac.webkit.org/changeset/266895>
Comment 11 Chris Dumez 2020-09-14 09:18:24 PDT
Created attachment 408710 [details]
Patch
Comment 12 Chris Dumez 2020-09-14 09:18:45 PDT
(In reply to Chris Dumez from comment #11)
> Created attachment 408710 [details]
> Patch

New approach so requesting review again.
Comment 13 Alex Christensen 2020-09-14 09:20:48 PDT
Comment on attachment 408710 [details]
Patch

For some reason I don't understand, I think this is better than bundle SPI.
I think it would be even better to modify the test to have different output (just PASS/FAIL instead of printing audio sample rates) but this is fine too.
Comment 14 Chris Dumez 2020-09-14 10:01:00 PDT
Comment on attachment 408710 [details]
Patch

Clearing flags on attachment: 408710

Committed r267018: <https://trac.webkit.org/changeset/267018>
Comment 15 Chris Dumez 2020-09-14 10:01:03 PDT
All reviewed patches have been landed.  Closing bug.