Bug 145064

Summary: AudioContext resume/close/suspend should reject promises with a DOM exception in lieu of throwing exceptions
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, commit-queue, darin, jer.noble, rniwa, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews100 for mac-mavericks
none
Archive of layout-test-results from ews104 for mac-mavericks-wk2
none
Fixing TypeError message
none
Patch none

youenn fablet
Reported 2015-05-15 11:47:30 PDT
WebKit current implementation of AudioContext resume, close and suspend may throw exceptions in case of error. It would make more sense to reject the promise with the exception as value. This would be more consistent with other promise based APIs.
Attachments
Patch (16.97 KB, patch)
2015-05-16 14:28 PDT, youenn fablet
no flags
Archive of layout-test-results from ews100 for mac-mavericks (675.43 KB, application/zip)
2015-05-16 15:38 PDT, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-mavericks-wk2 (723.75 KB, application/zip)
2015-05-16 15:45 PDT, Build Bot
no flags
Fixing TypeError message (19.26 KB, patch)
2015-05-17 10:01 PDT, youenn fablet
no flags
Patch (19.36 KB, patch)
2015-05-20 12:21 PDT, youenn fablet
no flags
Jer Noble
Comment 1 2015-05-15 13:23:41 PDT
That will require a spec change. I encourage you to file a spec bug at https://github.com/WebAudio/web-audio-api.
youenn fablet
Comment 2 2015-05-15 13:33:50 PDT
(In reply to comment #1) > That will require a spec change. I encourage you to file a spec bug at > https://github.com/WebAudio/web-audio-api. I just checked and the issue is already filed and apparently on its way to be landed in the spec: https://github.com/WebAudio/web-audio-api/issues/441
Jer Noble
Comment 3 2015-05-15 14:12:30 PDT
Ok then!
youenn fablet
Comment 4 2015-05-16 14:28:32 PDT
Build Bot
Comment 5 2015-05-16 15:38:18 PDT
Comment on attachment 253274 [details] Patch Attachment 253274 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/4657628286287872 New failing tests: fast/dom/document-contentType-DOMParser.html fast/dom/xmlserializer-serialize-to-string-exception.html media/track/regions-webvtt/vtt-region-constructor.html fast/dom/DOMURL/set-href-attribute-pathname.html fast/canvas/canvas-imageData.html fast/canvas/canvas-2d-imageData-create-nonfinite.html fast/dom/DOMURL/set-href-attribute-hostname.html fast/canvas/canvas-putImageData.html fast/dom/DOMURL/set-href-attribute-host.html fast/dom/DOMURL/url-constructor.html fast/canvas/canvas-getImageData-invalid.html fast/canvas/radialGradient-infinite-values.html fast/dom/DOMURL/set-href-attribute-hash.html fast/canvas/linearGradient-infinite-values.html
Build Bot
Comment 6 2015-05-16 15:38:21 PDT
Created attachment 253277 [details] Archive of layout-test-results from ews100 for mac-mavericks The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-mavericks Platform: Mac OS X 10.9.5
Build Bot
Comment 7 2015-05-16 15:45:41 PDT
Comment on attachment 253274 [details] Patch Attachment 253274 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/5251477308178432 New failing tests: fast/dom/document-contentType-DOMParser.html fast/canvas/radialGradient-infinite-values.html fast/dom/xmlserializer-serialize-to-string-exception.html fast/canvas/linearGradient-infinite-values.html media/track/regions-webvtt/vtt-region-constructor.html storage/indexeddb/objectstore-cursor.html fast/canvas/canvas-imageData.html fast/canvas/canvas-2d-imageData-create-nonfinite.html fast/dom/DOMURL/set-href-attribute-hostname.html fast/canvas/canvas-putImageData.html fast/dom/DOMURL/set-href-attribute-host.html fast/canvas/canvas-getImageData-invalid.html fast/dom/DOMURL/set-href-attribute-pathname.html fast/dom/DOMURL/url-constructor.html storage/indexeddb/intversion-bad-parameters.html fast/dom/DOMURL/set-href-attribute-hash.html
Build Bot
Comment 8 2015-05-16 15:45:43 PDT
Created attachment 253278 [details] Archive of layout-test-results from ews104 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
youenn fablet
Comment 9 2015-05-17 10:01:50 PDT
Created attachment 253284 [details] Fixing TypeError message
youenn fablet
Comment 10 2015-05-17 10:52:03 PDT
Comment on attachment 253284 [details] Fixing TypeError message View in context: https://bugs.webkit.org/attachment.cgi?id=253284&action=review > Source/WebCore/Modules/webaudio/AudioContext.cpp:-1115 > - scriptExecutionContext()->postTask(successCallback); Calling postTask here is unneeded as the promise will call the JS resolve callback through postTask anyway > Source/WebCore/Modules/webaudio/AudioContext.cpp:1120 > + failureCallback(0); This is a way to reject with no value, using the same mechanism as other error promise rejection. It seems better than to keep using a ExceptionCode that would be used to reject the promise in the custom binding code. In the future, successCallback may also take a std::nullptr_t to make promise rejection/resolution consistent and potentially automated by code generator.
Jer Noble
Comment 11 2015-05-18 17:21:54 PDT
Comment on attachment 253284 [details] Fixing TypeError message View in context: https://bugs.webkit.org/attachment.cgi?id=253284&action=review >> Source/WebCore/Modules/webaudio/AudioContext.cpp:-1115 >> - scriptExecutionContext()->postTask(successCallback); > > Calling postTask here is unneeded as the promise will call the JS resolve callback through postTask anyway I don't believe that is true, unless the Promise code has drastically changed lately.
youenn fablet
Comment 12 2015-05-19 01:49:48 PDT
(In reply to comment #11) > Comment on attachment 253284 [details] > Fixing TypeError message > > View in context: > https://bugs.webkit.org/attachment.cgi?id=253284&action=review > > >> Source/WebCore/Modules/webaudio/AudioContext.cpp:-1115 > >> - scriptExecutionContext()->postTask(successCallback); > > > > Calling postTask here is unneeded as the promise will call the JS resolve callback through postTask anyway > > I don't believe that is true, unless the Promise code has drastically > changed lately. My comment was not very clear, here is a longer rephrasing. The spec says that the promise should be immediately resolved if the audio context state is already suspended. The current implementation does not do that immediately but after a micro-task. The JS function assigned to the promise through Promise.then() will be called asynchronously by the JS promise anyway. I believe that this is implemented by postTask but maybe I am wrong here. Let's split that as a separate bug then.
youenn fablet
Comment 13 2015-05-19 01:56:14 PDT
(In reply to comment #12) > (In reply to comment #11) > > Comment on attachment 253284 [details] > > Fixing TypeError message > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=253284&action=review > > > > >> Source/WebCore/Modules/webaudio/AudioContext.cpp:-1115 > > >> - scriptExecutionContext()->postTask(successCallback); > > > > > > Calling postTask here is unneeded as the promise will call the JS resolve callback through postTask anyway > > > > I don't believe that is true, unless the Promise code has drastically > > changed lately. > > My comment was not very clear, here is a longer rephrasing. > > The spec says that the promise should be immediately resolved if the audio > context state is already suspended. The current implementation does not do > that immediately but after a micro-task. > > The JS function assigned to the promise through Promise.then() will be > called asynchronously by the JS promise anyway. I believe that this is > implemented by postTask but maybe I am wrong here. > > Let's split that as a separate bug then. Filed bug 145164, a 100 above this bug ;)
Darin Adler
Comment 14 2015-05-19 09:13:10 PDT
Comment on attachment 253284 [details] Fixing TypeError message View in context: https://bugs.webkit.org/attachment.cgi?id=253284&action=review > Source/JavaScriptCore/runtime/Error.h:59 > -JS_EXPORT_PRIVATE JSObject* createTypeError(ExecState*, const String&); > +JS_EXPORT_PRIVATE JSObject* createTypeError(ExecState*, const String& message = ASCIILiteral("Type error")); This creates unnecessary code bloat as each call site generates the literal. It’s better to overload instead of using a default argument value. > Source/WebCore/bindings/js/JSDOMBinding.h:253 > // Convert a DOM implementation exception code into a JavaScript exception in the execution state. This comment describes the second function below; it’s not good to have it immediately before a function that does something subtly different!
youenn fablet
Comment 15 2015-05-20 12:21:51 PDT
WebKit Commit Bot
Comment 16 2015-05-20 13:20:19 PDT
Comment on attachment 253455 [details] Patch Clearing flags on attachment: 253455 Committed r184651: <http://trac.webkit.org/changeset/184651>
WebKit Commit Bot
Comment 17 2015-05-20 13:20:22 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.