Closed
Bug 822135
Opened 12 years ago
Closed 3 years ago
Disable Profiler when there's a Private Browsing Window
Categories
(Core :: Gecko Profiler, defect)
Tracking
()
RESOLVED
FIXED
mozilla21
People
(Reporter: BenWa, Assigned: BenWa)
References
Details
Attachments
(3 files, 3 obsolete files)
6.84 KB,
patch
|
BenWa
:
review+
|
Details | Diff | Splinter Review |
2.03 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
40 bytes,
text/x-review-board-request
|
Details |
The profiler isn't tab aware and it's far from a simple job. For now I discussed this with Ehsan that opening the first private window should force disable the profiler and that closing the last private window should restore the state.
Ehsan/Josh what are the right events to listen for? Since the profiler devtools panel is now landed I think this should live in the profiler xpcom module so it can be shared between the two.
Comment 1•12 years ago
|
||
There's no event for the first opening of a private window right now. It would be nice to avoid requiring one as well. As for closing, that's last-pb-context-exited.
Assignee | ||
Comment 2•12 years ago
|
||
(In reply to Josh Matthews [:jdm] from comment #1)
> There's no event for the first opening of a private window right now. It
> would be nice to avoid requiring one as well. As for closing, that's
> last-pb-context-exited.
What about knowing when <i>a</i> private window is open? Otherwise we could have a PB poke the profiler specifically if we don't want to introduce events for others to misuse.
Comment 3•12 years ago
|
||
You could presumably just iterate through the open windows and check PrivateBrowsingUtils.isWindowPrivate to get that information.
Assignee | ||
Comment 4•12 years ago
|
||
Assignee: nobody → bgirard
Status: NEW → ASSIGNED
Attachment #693046 -
Flags: review?(josh)
Attachment #693046 -
Flags: review?(ehsan)
Comment 5•12 years ago
|
||
Comment on attachment 693046 [details] [diff] [review]
patch
Review of attachment 693046 [details] [diff] [review]:
-----------------------------------------------------------------
::: tools/profiler/nsIProfiler.idl
@@ +5,5 @@
>
> #include "nsISupports.idl"
>
> [scriptable, uuid(c94651cf-082f-45e2-9481-33a1a700b46a)]
> +interface nsIProfiler : nsISupports
Revert.
::: tools/profiler/nsProfiler.cpp
@@ +30,5 @@
> {
> + nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
> + if (observerService) {
> + observerService->AddObserver(this, "chrome-document-global-created", false);
> + observerService->AddObserver(this, "last-pb-context-exited", false);
Doing this in the constructor is dangerous, since the refcount is 0. Move this to an Init function.
@@ +43,5 @@
> + if (strcmp(aTopic, "chrome-document-global-created") == 0) {
> + nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(aSubject);
> + nsCOMPtr<nsIWebNavigation> parentWebNav = do_GetInterface(requestor);
> + nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(parentWebNav);
> + if (loadContext->UsePrivateBrowsing() && !mLockedForPrivateBrowsing) {
Definitely need a null check here; the do_Foo ones are null safe though.
@@ +59,5 @@
> nsProfiler::StartProfiler(uint32_t aEntries, uint32_t aInterval,
> const char** aFeatures, uint32_t aFeatureCount)
> {
> + if (mLockedForPrivateBrowsing) {
> + // TODO How do we return an warning?
What kind of warning are you looking for? NS_ERROR_NOT_AVAILABLE will translate to a JS exception if this is called through XPConnect.
::: tools/profiler/nsProfiler.h
@@ +20,5 @@
> NS_DECL_NSIPROFILER
> +
> + NS_IMETHODIMP Observe(nsISupports *aSubject,
> + const char *aTopic,
> + const PRUnichar *aData);
NS_DECL_NSIOBSERVER
Attachment #693046 -
Flags: review?(josh)
Assignee | ||
Comment 6•12 years ago
|
||
Attachment #693046 -
Attachment is obsolete: true
Attachment #693046 -
Flags: review?(ehsan)
Attachment #693147 -
Flags: review?(josh)
Comment 7•12 years ago
|
||
Comment on attachment 693147 [details] [diff] [review]
patch
Review of attachment 693147 [details] [diff] [review]:
-----------------------------------------------------------------
Have you tested that this does what you want?
Attachment #693147 -
Flags: review?(josh) → review+
Assignee | ||
Comment 8•12 years ago
|
||
Yes, it make it impossible to use the profiler from the profiler module. However it's still possible to control the profiler from sampler.h if the platform code really wanted to profile.
Assignee | ||
Updated•12 years ago
|
Attachment #693147 -
Flags: review?(ehsan)
Comment 9•12 years ago
|
||
Comment on attachment 693147 [details] [diff] [review]
patch
I think Josh's review is enough here. If you really want my review on this, please re-request but I won't get to it until Thursday...
Attachment #693147 -
Flags: review?(ehsan)
Assignee | ||
Comment 10•12 years ago
|
||
Sounds good to me
https://tbpl.mozilla.org/?tree=Try&rev=f6b072f12e3a
Flags: needinfo?(bgirard)
Assignee | ||
Comment 11•12 years ago
|
||
Comment 12•12 years ago
|
||
FWIW "chrome-document-global-created" doesn't fire for some of the windows, so this patch will not always do the right thing.
Assignee | ||
Comment 14•12 years ago
|
||
Attachment #693147 -
Attachment is obsolete: true
Attachment #700724 -
Flags: review+
Assignee | ||
Comment 15•12 years ago
|
||
Assignee | ||
Comment 16•12 years ago
|
||
Attachment #700724 -
Attachment is obsolete: true
Attachment #701119 -
Flags: review+
Assignee | ||
Comment 17•12 years ago
|
||
Comment 18•12 years ago
|
||
Comment on attachment 701119 [details] [diff] [review]
patch r=jdm
>+nsProfiler::~nsProfiler()
>+{
>+ nsCOMPtr<nsIObserverService> observerService = >mozilla::services::GetObserverService();
>+ if (observerService) {
>+ observerService->RemoveObserver(this, "chrome-document-global-created");
>+ observerService->RemoveObserver(this, "last-pb-context-exited");
>+ }
>+}
This won't work quite right. AddObserver is taking a strong reference to nsProfiler, so it will leak. You should probably just make it inherit from nsSupportsWeakReference, QI to nsISupportsWeakReference, and pass true to AddObserver to make it take a weak reference.
Assignee | ||
Comment 19•12 years ago
|
||
Attachment #701172 -
Flags: review?(ehsan)
Comment 20•12 years ago
|
||
Comment on attachment 701172 [details] [diff] [review]
fix reference
Review of attachment 701172 [details] [diff] [review]:
-----------------------------------------------------------------
::: tools/profiler/nsProfiler.h
@@ +12,3 @@
> #include "mozilla/Attributes.h"
>
> +class nsProfiler MOZ_FINAL : public nsIProfiler, public nsIObserver, public nsSupportsWeakReference
Nit: use the Enter key. ;-)
Attachment #701172 -
Flags: review?(ehsan) → review+
Comment 21•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Assignee | ||
Comment 22•12 years ago
|
||
Opps I forgot to land this.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 23•9 years ago
|
||
Bug 822135 - Fix nsProfiler observer strong reference. r=ehsan
Assignee | ||
Comment 24•9 years ago
|
||
Comment on attachment 8668584 [details]
MozReview Request: Bug 822135 - Fix nsProfiler observer strong reference. r=ehsan
Bug 822135 - Fix nsProfiler observer strong reference. r=ehsan
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(bgirard)
Assignee | ||
Comment 25•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/8f489e406701f08833fae12f66ab22f5a0d0315e
Bug 822135 - Fix nsProfiler observer strong reference. r=ehsan
Backed out for mochitest-dt failures like https://treeherder.mozilla.org/logviewer.html#?job_id=15123310&repo=mozilla-inbound
https://hg.mozilla.org/integration/mozilla-inbound/rev/fc03c84dfccb
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(bgirard)
Assignee | ||
Updated•8 years ago
|
Assignee: bgirard → nobody
The main patch landed in Dec 2012, so I'm calling this bug fixed.
Status: REOPENED → RESOLVED
Closed: 12 years ago → 3 years ago
Resolution: --- → FIXED
Updated•3 years ago
|
Assignee: nobody → b56girard
You need to log in
before you can comment on or make changes to this bug.
Description
•