Implement GetName or GetNameForLogging for WebContentsObservers |
|||
Issue descriptionThis has been extremely useful for things like NavigationThrottles, where we can easily name the throttle for tracing, etc. Nasko: If you want also timing information, we could do the same thing as we have done with NavigationThrottles - define a GetName() like API that observers implement, so we can tell how long which ones takes. We will likely have to avoid making it pure virtual, but having a default name that is something like "unknown" while implementing it in our entire codebase will be a good compromise. We have discussed this in the past, so I'm supportive if someone wants to get it done.
,
Dec 13 2017
Maybe our goal shouldn't be to make this pure virtual in the end, but rather "here is a method you can override to automatically trace your WCO". So performance conscious observers can do it without adding their own traces.
,
Dec 13 2017
My initial comment did say we should not make it pure virtual, not only for size reasons, but also for content/public/ API reasons. Also, thanks for digging into the details of this, that's a LOT of WCOs :). While I'd love the debuggability, it does seem too high of a price to pay for this. Maybe we can log a counter or the address? I think ordering is more or less reproducible within a build, so if we log that, we would have reasonable way of identifying the WCO we care about in a local build/repro. What do you think?
,
Dec 13 2017
Also, let me add some other folks that have griped about WCOs doing things they should not be doing :).
,
Dec 13 2017
Adding a counter / address sounds reasonable to me. An address is probably a tiny bit more actionable since I'm nervous a counter could hit weird off-by-one issues wrt observers adding / removing themselves dynamically.
,
Dec 13 2017
The counter would be a local variable that is incremented on each iteration of the loop. It should not be used for control flow. The problem with addresses is that with properly functioning ASLR, you will not be able to reproduce in another run of the browser. While even with off by 1 or 2, you have reasonably decreased the search space and the behavior will likely be identical between runs with the same repro steps.
,
Feb 26 2018
Back to Available. Maybe if I have some time later though :) In investigating this I found some slow Java WebContentsObservers (or TabObservers, what have you). Could probably win some ms on Android from optimizing them. |
|||
►
Sign in to add a comment |
|||
Comment 1 by csharrison@chromium.org
, Dec 13 2017