RESOLVED FIXED 206478
[Cocoa] Media mime types map should be created in the UI process
https://bugs.webkit.org/show_bug.cgi?id=206478
Summary [Cocoa] Media mime types map should be created in the UI process
Per Arne Vollan
Reported 2020-01-18 17:34:09 PST
Creating this map in the WebContent process will access the launch services daemon, which will be blocked.
Attachments
Patch (18.92 KB, patch)
2020-01-18 17:44 PST, Per Arne Vollan
no flags
Patch (18.92 KB, patch)
2020-01-18 17:53 PST, Per Arne Vollan
no flags
Patch (18.92 KB, patch)
2020-01-18 18:09 PST, Per Arne Vollan
no flags
Patch (19.63 KB, patch)
2020-01-18 18:21 PST, Per Arne Vollan
no flags
Patch (19.19 KB, patch)
2020-01-18 18:34 PST, Per Arne Vollan
darin: review+
Patch (23.28 KB, patch)
2020-01-23 14:55 PST, Per Arne Vollan
no flags
Patch (23.31 KB, patch)
2020-01-23 15:31 PST, Per Arne Vollan
no flags
Patch (23.26 KB, patch)
2020-01-24 11:56 PST, Per Arne Vollan
no flags
Radar WebKit Bug Importer
Comment 1 2020-01-18 17:34:33 PST
Per Arne Vollan
Comment 2 2020-01-18 17:44:34 PST
Per Arne Vollan
Comment 3 2020-01-18 17:53:44 PST
Per Arne Vollan
Comment 4 2020-01-18 18:09:49 PST
Per Arne Vollan
Comment 5 2020-01-18 18:21:58 PST
Per Arne Vollan
Comment 6 2020-01-18 18:34:17 PST
Sam Weinig
Comment 7 2020-01-19 10:51:46 PST
What happens if the mapping of mime types reported by launch services changes during the lifetime of the process?
Darin Adler
Comment 8 2020-01-20 11:38:43 PST
Comment on attachment 388167 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=388167&action=review Not sure what the Windows failure on EWS is about. > Source/WebCore/platform/MIMETypeRegistry.cpp:285 > + // A table of common media MIME types and file extentions used when a platform's Spelling error here. It’s extensions, not "extentions". > Source/WebCore/platform/MIMETypeRegistry.cpp:287 > + static NeverDestroyed<std::initializer_list<TypeExtensionPair>> commonMediaTypes; Should be able to use constexpr for this whole thing rather than needing code to initialize it. > Source/WebCore/platform/MIMETypeRegistry.cpp:290 > + static std::once_flag onceFlag; > + std::call_once( Surprised we need this. Is this called from multiple threads? If not then we should just be able to use "= [] {" instead of all the call_once stuff as is done in many other places in WebKit such as canAtttachAuthorShadowRoot, hasEffectiveDisplayNoneForDisplayContents, etc. > Source/WebCore/platform/MIMETypeRegistry.cpp:381 > + static std::once_flag onceFlag; > + std::call_once( Ditto.
Per Arne Vollan
Comment 9 2020-01-21 12:06:16 PST
(In reply to Sam Weinig from comment #7) > What happens if the mapping of mime types reported by launch services > changes during the lifetime of the process? Good point! There should be no behavior change with this patch. The only difference is that we create the cached map in the UI process instead of in the WebContent process. Thanks for reviewing!
Per Arne Vollan
Comment 10 2020-01-21 12:08:18 PST
(In reply to Darin Adler from comment #8) > Comment on attachment 388167 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=388167&action=review > > Not sure what the Windows failure on EWS is about. > > > Source/WebCore/platform/MIMETypeRegistry.cpp:285 > > + // A table of common media MIME types and file extentions used when a platform's > > Spelling error here. It’s extensions, not "extentions". > > > Source/WebCore/platform/MIMETypeRegistry.cpp:287 > > + static NeverDestroyed<std::initializer_list<TypeExtensionPair>> commonMediaTypes; > > Should be able to use constexpr for this whole thing rather than needing > code to initialize it. > > > Source/WebCore/platform/MIMETypeRegistry.cpp:290 > > + static std::once_flag onceFlag; > > + std::call_once( > > Surprised we need this. Is this called from multiple threads? If not then we > should just be able to use "= [] {" instead of all the call_once stuff as is > done in many other places in WebKit such as canAtttachAuthorShadowRoot, > hasEffectiveDisplayNoneForDisplayContents, etc. > > > Source/WebCore/platform/MIMETypeRegistry.cpp:381 > > + static std::once_flag onceFlag; > > + std::call_once( > > Ditto. You're right. I don't believe we need this, since the function did not use call_once originally. I will update the patch, possibly asserting that this code is being run on the main thread. Thanks for reviewing!
Sam Weinig
Comment 11 2020-01-22 14:45:19 PST
(In reply to Per Arne Vollan from comment #9) > (In reply to Sam Weinig from comment #7) > > What happens if the mapping of mime types reported by launch services > > changes during the lifetime of the process? > > Good point! There should be no behavior change with this patch. The only > difference is that we create the cached map in the UI process instead of in > the WebContent process. > Sounds like there would be a subtle behavior change then, since the cache will now not be invalidated for the life of the UIProcess, whereas, on each WebProcess creation we used to get a fresh copy.
Per Arne Vollan
Comment 12 2020-01-22 14:58:36 PST
(In reply to Sam Weinig from comment #11) > (In reply to Per Arne Vollan from comment #9) > > (In reply to Sam Weinig from comment #7) > > > What happens if the mapping of mime types reported by launch services > > > changes during the lifetime of the process? > > > > Good point! There should be no behavior change with this patch. The only > > difference is that we create the cached map in the UI process instead of in > > the WebContent process. > > > > Sounds like there would be a subtle behavior change then, since the cache > will now not be invalidated for the life of the UIProcess, whereas, on each > WebProcess creation we used to get a fresh copy. Ah, yes, that is a good point! We could possibly recreate the map every time we create a new WebContent process, but that would be less performant than just using the previous one.
Per Arne Vollan
Comment 13 2020-01-23 14:55:38 PST
Per Arne Vollan
Comment 14 2020-01-23 15:31:41 PST
WebKit Commit Bot
Comment 15 2020-01-23 19:19:00 PST
Comment on attachment 388601 [details] Patch Clearing flags on attachment: 388601 Committed r255050: <https://trac.webkit.org/changeset/255050>
Sam Weinig
Comment 16 2020-01-24 08:07:53 PST
Probably worth investigating whether one already exists / filing a radar for a callback from launch services that tells you if it changes.a
Per Arne Vollan
Comment 17 2020-01-24 10:53:07 PST
Reverted r255050 for reason: Introduced crashes on bots Committed r255081: <https://trac.webkit.org/changeset/255081>
Per Arne Vollan
Comment 18 2020-01-24 11:56:51 PST
Per Arne Vollan
Comment 19 2020-01-24 12:43:10 PST
(In reply to Sam Weinig from comment #16) > Probably worth investigating whether one already exists / filing a radar for > a callback from launch services that tells you if it changes.a Thanks! I am looking into this now.
Per Arne Vollan
Comment 20 2020-01-24 13:23:53 PST
(In reply to Per Arne Vollan from comment #19) > (In reply to Sam Weinig from comment #16) > > Probably worth investigating whether one already exists / filing a radar for > > a callback from launch services that tells you if it changes.a > > Thanks! I am looking into this now. There appears to be an existing mechanism for this.
WebKit Commit Bot
Comment 21 2020-01-25 08:51:40 PST
Comment on attachment 388714 [details] Patch Clearing flags on attachment: 388714 Committed r255119: <https://trac.webkit.org/changeset/255119>
Note You need to log in before you can comment on or make changes to this bug.