Cocoa browser window resize performance analysis |
|||
Issue descriptionChrome Version : 56.0.2914.3 OS Version: OS X 10.12.1 We want to examine the influence / overheads of layout when resizing a browser window. What steps will reproduce the problem? 1. Open about:blank in Canary 2. Open activity monitor, sample 3. Quickly select the browser window and resize it aggresively What is the expected result? Buttery smooth resize What happens instead of that? Resize uses noticeable CPU and runs at <60 Hz. Trace attached. Some highlights Autolayout is present, but it's not a major contributor. Significant overhead is in ObjC cruft and memory management. 2309 / 3000 samples has us "inside" a message loop (i.e not waiting for an event). Using that as 100% baseline. 2248 under handling of the mouse event for resize (i.e. most of it) 56% (1287/2309) is under [NSWindow _setFrame:updateBorderViewSize:] 36% (834/2309) of the time is latency (and a tiny bit of frame swap CPU time), under content::RenderWidgetHostImpl::PauseForPendingResizeOrRepaints() 20% remains: maybe half is autolayout, and the other half is other stuff we trigger (some probably avoidable): There are many calls to ScreenMac::GetDisplayNearestWindow via various stacks. These calls are not cheap within AppKit (wait_for_user_home_dir?? get_bool_user_preference_for_key? SLDisplayUsesForceToGray? ICCProfile::FromCGColorSpace(CGColorSpace*)?) 1.6% in [AutocompleteTextField setFrame:]. About one third is autolayout. - a call to LocationBarViewMac::UpdateLocationIcon() which invokes NSImageFromImageSkiaWithColorSpace every time!? - and BubbleDecoration::SetImage, ChromeToolbarModelDelegate::GetSecurityLevel() [NSView _postFrameChangeNotification] calls all over the place. ** -[BookmarkBarController reconfigureBookmarkBar] is one subscriber ** 2.5% of CPU time ** - calls [NSView removeFromSuperview] and does lots of NSString rendering - [GradientButtonCell initTextCell:] ** Invoked again! via BackgroundGradientView setFrameSize, AutocompleteTextField addToolTip: 9+3 samples (0.5%) at -[NSView _verifyConstraintsForCurrentFrame] under [WebContentsViewCocoa setFrameSize:] I only got 2 samples at -[NSView(NSConstraintBasedLayout) under RenderWidgetHostViewCocoa setFrameSize (i.e. <0.1%) == 1022 / 2309 samples not in [NSWindow _setFrame:updateBorderViewSize:] == 208 samples for NSWindow frame setting 545 samples for *drawing* (CA::Transaction::commit()) ~110 samples latency - waiting for event 10 samples in *validating* constraints remainder in small posted tasks, autorelease pool draining (NSBitmapImageRep!) minor contributors, but annoying content::IsUseZoomForDSFEnabled() -- called a lot. Does a std::map traversal (command line flags?)
,
Nov 20 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7330ed4e42141778cb25604dd4949471f034a38f commit 7330ed4e42141778cb25604dd4949471f034a38f Author: tapted <tapted@chromium.org> Date: Sun Nov 20 23:48:55 2016 Mac: Use a cache for ScreenMac::GetDisplayForScreen(). Performance traces on the associated bugs turn up a lot of time spent in display::screen_mac::GetDisplayForScreen(). It does a lot of work, and calls some expensive AppKit and CoreGraphics methods. It's currently invoked multiple times during a window resize. GetDisplayNearestWindow would also invoke -[NSWindow _bestScreenBySpaceAssignmentOrGeometry] which does some synchronous messaging with the window server process, adding significant latency. ScreenMac already maintains a std::vector<Display>, but GetDisplayForScreen() does not use it. Use it. Optimize GetDisplayNearestWindow for the case of a single display. BUG= 666556 , 665280 Review-Url: https://codereview.chromium.org/2514703002 Cr-Commit-Position: refs/heads/master@{#433463} [modify] https://crrev.com/7330ed4e42141778cb25604dd4949471f034a38f/ui/display/mac/screen_mac.mm
,
Oct 31 2017
,
Sep 13
Archiving old bugs that haven't been actively assigned in over 180 days. If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!
,
Sep 13
Archiving old bugs that haven't been actively assigned in over 180 days. If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!
,
Sep 13
Archiving old bugs that haven't been actively assigned in over 180 days. If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!
,
Sep 13
Archiving old bugs that haven't been actively assigned in over 180 days. If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks! |
|||
►
Sign in to add a comment |
|||
Comment 1 by ajha@chromium.org
, Nov 18 2016