Closed Bug 1463908 Opened 6 years ago Closed 6 years ago

tooltip text provider uses about 20KB of memory per-process

Categories

(Firefox :: General, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 62
Tracking Status
firefox62 --- fixed

People

(Reporter: bzbarsky, Assigned: Felipe)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxperf:p1])

Attachments

(1 file)

It's not a huge thing, but we have a JS-implemented default tooltip text provider and instantiating that service (which we do in all content processes via the ChromeTooltipListener) costs about 20KB of RAM.
Maybe Felipe has ideas here. :-)
Flags: needinfo?(felipc)
From what I found, the default tooltip provider is something that is needed in content processes, as it's responsible for providing tooltips for a lot of things (e.g., <input file>), etc.

However, it shouldn't need to be instantiated until getNodeText is called, from sTooltipCallback.

There are three options that we could do to reduce this memory overhead:

A) Rewrite the default tooltip provider in C++ so it doesn't have a per-process memory cost
B) Lazily instantiate the ChromeTooltipListener
C) Lazily instantiate the default tooltip provider


Option C) is super easy (as it is instantiated in the ChromeTooltipListener constructor, but it could be only when sTooltipCallback is called), and it should be more than enough to make this no longer an issue, so I'm gonna go with it as it's the simplest one.
Assignee: nobody → felipc
Status: NEW → ASSIGNED
Flags: needinfo?(felipc)
Two things: I initially wrote this just returning a raw pointer, but I wasn't sure if it was certain that the object could be gone by the time this is called..  Thinking more about it, I think it would be ok

There's a change in behavior in that, if the do_getService calls fail, it will keep retrying now.. I believe it doesn't matter for Firefox, but let me know if I should keep the old behavior
Comment on attachment 8981300 [details]
Bug 1463908 - Lazily instatiate the tooltip text provider.

https://reviewboard.mozilla.org/r/247406/#review254156

::: docshell/base/nsDocShellTreeOwner.h:172
(Diff revision 1)
>    NS_IMETHOD HideTooltip();
>  
>    nsWebBrowser* mWebBrowser;
>    nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
>    nsCOMPtr<nsITooltipTextProvider> mTooltipTextProvider;
> +  already_AddRefed<nsITooltipTextProvider> GetTooltipTextProvider();

Please put the methe next to the other methods, before the data members start.

::: docshell/base/nsDocShellTreeOwner.cpp:1063
(Diff revision 1)
>      mTooltipTextProvider = do_GetService(NS_DEFAULTTOOLTIPTEXTPROVIDER_CONTRACTID);
>    }
> -}
>  
> -ChromeTooltipListener::~ChromeTooltipListener()
> -{
> +  nsCOMPtr<nsITooltipTextProvider> provider = mTooltipTextProvider;
> +  return provider.forget();

Could also just return mTooltipTextProvider and change the return type to nsITooltipTextProvider*.
Attachment #8981300 - Flags: review?(bzbarsky) → review+
Pushed by felipc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/53732e14e552
Lazily instatiate the tooltip text provider. r=bz
Whiteboard: [fxperf:p1]
https://hg.mozilla.org/mozilla-central/rev/53732e14e552
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 62
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: