RESOLVED CONFIGURATION CHANGED 214896
ProcessThrottler should register itself as client to its new assertion if already registered to the old assertion
https://bugs.webkit.org/show_bug.cgi?id=214896
Summary ProcessThrottler should register itself as client to its new assertion if alr...
youenn fablet
Reported 2020-07-28 14:36:44 PDT
ProcessThrottler should register itself as client to its new assertion if already registered to the old assertion
Attachments
Patch (2.29 KB, patch)
2020-07-28 14:41 PDT, youenn fablet
no flags
Patch (7.26 KB, patch)
2020-07-29 02:30 PDT, youenn fablet
cdumez: review-
cdumez: commit-queue-
youenn fablet
Comment 1 2020-07-28 14:41:15 PDT
Chris Dumez
Comment 2 2020-07-28 14:49:59 PDT
Comment on attachment 405416 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405416&action=review > Source/WebKit/UIProcess/ProcessThrottler.cpp:138 > + m_assertion->setClient(*this); Good catch but I think this should be done unconditionally.
Chris Dumez
Comment 3 2020-07-28 14:51:50 PDT
Comment on attachment 405416 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405416&action=review >> Source/WebKit/UIProcess/ProcessThrottler.cpp:138 >> + m_assertion->setClient(*this); > > Good catch but I think this should be done unconditionally. Also we probably want to drop the m_assertion->setClient(*this) call in ProcessThrottler::didConnectToProcess()
Chris Dumez
Comment 4 2020-07-28 14:52:32 PDT
Comment on attachment 405416 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405416&action=review > Source/WebKit/UIProcess/ProcessThrottler.cpp:129 > + bool hasClient = !!m_assertion->client(); m_assertion can be null so this will crash.
youenn fablet
Comment 5 2020-07-29 02:30:42 PDT
youenn fablet
Comment 6 2020-07-29 02:31:07 PDT
Chris Dumez
Comment 7 2020-07-29 09:20:31 PDT
Comment on attachment 405445 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405445&action=review > Source/WebKit/UIProcess/ProcessAssertion.h:69 > + ProcessAssertion(ProcessID, const String& reason, ProcessAssertionType, Client* = nullptr); It is not really less error-prone if the parameter is optional.. Also, why can it be null? > Source/WebKit/UIProcess/ProcessAssertion.h:100 > + ProcessAndUIAssertion(ProcessID, const String& reason, ProcessAssertionType, Client* = nullptr); Ditto. > Source/WebKit/UIProcess/ProcessThrottler.h:54 > +class ProcessThrottler : public CanMakeWeakPtr<ProcessThrottler>, public ProcessAssertion::Client { Why is this needed?
Chris Dumez
Comment 8 2020-07-29 09:24:11 PDT
Comment on attachment 405445 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405445&action=review >> Source/WebKit/UIProcess/ProcessAssertion.h:69 >> + ProcessAssertion(ProcessID, const String& reason, ProcessAssertionType, Client* = nullptr); > > It is not really less error-prone if the parameter is optional.. Also, why can it be null? Ok, I see that ProcessAssertion is used by other things than ProcessThrottler (like DownloadMap) and those don't set themselves as client. So using a raw pointer seems OK. That said, I don't think the parameter should be optional. If it is optional, then it is not any less error-prone than setting the client later using a setter.
youenn fablet
Comment 9 2020-07-29 09:36:05 PDT
> Ok, I see that ProcessAssertion is used by other things than > ProcessThrottler (like DownloadMap) and those don't set themselves as > client. So using a raw pointer seems OK. That said, I don't think the > parameter should be optional. If it is optional, then it is not any less > error-prone than setting the client later using a setter. Plan is to make it mandatory and pass a ref instead of a pointer. But this should be a follow-up because of other assertions (download and media ones at least). Probably we should be also using a WeakPtr instead of a pointer.
youenn fablet
Comment 10 2020-07-29 09:36:25 PDT
Keeping it optional just reduces the size of the patch basically.
Chris Dumez
Comment 11 2020-07-29 09:36:49 PDT
(In reply to youenn fablet from comment #9) > > Ok, I see that ProcessAssertion is used by other things than > > ProcessThrottler (like DownloadMap) and those don't set themselves as > > client. So using a raw pointer seems OK. That said, I don't think the > > parameter should be optional. If it is optional, then it is not any less > > error-prone than setting the client later using a setter. > > Plan is to make it mandatory and pass a ref instead of a pointer. > But this should be a follow-up because of other assertions (download and > media ones at least). > Probably we should be also using a WeakPtr instead of a pointer. I think parameter should be mandatory. Clients can explicitly pass null for now.
Chris Dumez
Comment 12 2020-07-29 09:37:14 PDT
(In reply to youenn fablet from comment #10) > Keeping it optional just reduces the size of the patch basically. But makes it error prone so I am against it.
Chris Dumez
Comment 13 2020-07-29 09:53:19 PDT
(In reply to youenn fablet from comment #10) > Keeping it optional just reduces the size of the patch basically. There are not that many call sites and it is just an extra parameter. If you want to keep the patch small, then we don't have to do the refactoring at all and we can keep setClient().
Chris Dumez
Comment 14 2020-07-30 10:24:10 PDT
I uploaded a refactoring proposal at Bug 214976 because I don't like the Client interface. If you land this fix first, I will rebase my patch.
Chris Dumez
Comment 15 2020-07-30 10:28:28 PDT
(In reply to Chris Dumez from comment #14) > I uploaded a refactoring proposal at Bug 214976 because I don't like the > Client interface. If you land this fix first, I will rebase my patch. My personal preference would be you landing the 2 line change to fix the bug here (moving setClient from didConnectToProcess to setAssertionType) and then doing the refactoring in Bug 214976.
youenn fablet
Comment 16 2020-08-03 00:53:31 PDT
Note You need to log in before you can comment on or make changes to this bug.