WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
215382
Deferred WKUserScripts are exponentially injected on preloaded pages with frames
https://bugs.webkit.org/show_bug.cgi?id=215382
Summary
Deferred WKUserScripts are exponentially injected on preloaded pages with frames
Timothy Hatcher
Reported
2020-08-11 10:24:46 PDT
We inject a web extension script multiple times per frame if the page is preloaded in Safari and has multiple frames. The number of times we inject is how many frames the page has. So this is exponential. <
rdar://problem/66837802
>
Attachments
Patch
(9.46 KB, patch)
2020-08-11 10:32 PDT
,
Timothy Hatcher
no flags
Details
Formatted Diff
Diff
Patch
(9.42 KB, patch)
2020-08-11 12:19 PDT
,
Timothy Hatcher
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Timothy Hatcher
Comment 1
2020-08-11 10:32:12 PDT
Created
attachment 406390
[details]
Patch
Geoffrey Garen
Comment 2
2020-08-11 10:44:49 PDT
Comment on
attachment 406390
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406390&action=review
r=me
> Source/WebCore/page/Frame.cpp:694 > +void Frame::injectUserScriptsAwaitingNotification() > +{ > + for (const auto& pair : m_userScriptsAwaitingNotification) > + injectUserScriptImmediately(pair.first, pair.second.get()); > + > + m_userScriptsAwaitingNotification.clear(); > +}
I prefer the idiom where you take() or WTFMove() or exchange() before entering the loop. This means the data member is always coherent, even during the loop. One reason this might matter is re-entrancy. But even if we think re-entrancy won't happen, I think the idiom is a bit clearer. In this case, you even get to delete a line of code: for (const auto& pair : std::exchange(m_userScriptsAwaitingNotification, { })) ...
Sam Weinig
Comment 3
2020-08-11 10:46:32 PDT
Comment on
attachment 406390
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406390&action=review
> Source/WebCore/page/Frame.cpp:690 > + for (const auto& pair : m_userScriptsAwaitingNotification)
You can use structured bindings to make this a bit nicer: for (const auto& [world, script] : m_userScriptsAwaitingNotification)
Sam Weinig
Comment 4
2020-08-11 10:47:35 PDT
Comment on
attachment 406390
[details]
Patch Eek, sorry, did not meant to change the review flag state.
Timothy Hatcher
Comment 5
2020-08-11 12:19:35 PDT
Created
attachment 406402
[details]
Patch
Timothy Hatcher
Comment 6
2020-08-11 12:20:22 PDT
Comment on
attachment 406390
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406390&action=review
>> Source/WebCore/page/Frame.cpp:690 >> + for (const auto& pair : m_userScriptsAwaitingNotification) > > You can use structured bindings to make this a bit nicer: > > for (const auto& [world, script] : m_userScriptsAwaitingNotification)
Cool. Did this.
>> Source/WebCore/page/Frame.cpp:694 >> +} > > I prefer the idiom where you take() or WTFMove() or exchange() before entering the loop. This means the data member is always coherent, even during the loop. One reason this might matter is re-entrancy. But even if we think re-entrancy won't happen, I think the idiom is a bit clearer. > > In this case, you even get to delete a line of code: > > for (const auto& pair : std::exchange(m_userScriptsAwaitingNotification, { })) > ...
Done.
EWS
Comment 7
2020-08-11 12:52:36 PDT
Committed
r265510
: <
https://trac.webkit.org/changeset/265510
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 406402
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug