[haiku-bugs] Re: [Haiku] #3011: Filling Tracker windows with many files takes too long

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Mon, 19 Aug 2019 04:51:57 -0000

#3011: Filling Tracker windows with many files takes too long
------------------------------------+---------------------------
   Reporter:  stippi                |      Owner:  leavengood
       Type:  enhancement           |     Status:  assigned
   Priority:  normal                |  Milestone:  Unscheduled
  Component:  Applications/Tracker  |    Version:  R1/pre-alpha1
 Resolution:                        |   Keywords:
 Blocked By:                        |   Blocking:  3974, 10952
Has a Patch:  0                     |   Platform:  All
------------------------------------+---------------------------

Comment (by leavengood):

 I have figured out the main problem here. In AddPoseToList, some weird
 BRect calculation is done and there is an "if" that is always true:


 {{{
 // we only care about the positions if this is a visible list
 poseBounds = CalcPoseRectList(pose, poseIndex);
 havePoseBounds = true;

 BRect srcRect(Extent());
 srcRect.top = poseBounds.top;
 srcRect = srcRect & viewBounds;
 BRect destRect(srcRect);
 destRect.OffsetBy(0, fListElemHeight);

 // special case the addition of a pose that scrolls
 // the extent into the view for the first time:
 if (destRect.bottom > viewBounds.top
         && destRect.top > destRect.bottom) {
         // make destRect valid
         destRect.top = viewBounds.top;
 }

 if (srcRect.Intersects(viewBounds)
         || destRect.Intersects(viewBounds)) {
 }}}

 At the moment I have no idea what srcRect and destRect are supposed to be,
 but they always seem to intersect with the view bounds, and this causes a
 synchronous draw for every pose added.

 When I changed this if to "if (poseBounds.Intersects(viewBounds)) {" only
 the actual visible poses are drawn and my big directory of empty files
 loads in a second.

 But now some bad news: this code must serve some purpose because with the
 above change I get some drawing artifacts if opening a directory scrolled
 down at all (Tracker remembers your scroll position.)

 As has been noted many times PoseView is a big mess. I do not know if I
 want to do a major refactoring at the moment, but I can make things much
 better and faster if I can understand the purpose of this code and only
 trigger drawing when it is truly needed.

 I'll keep studying it and try to understand how scrolling changes the
 behavior here.

 I think I can write out what it should be doing and the corner cases and
 maybe use that as a template to make a new version of AddPoseToList.

 I think a big part of the issue here is the contents of the directory are
 returned in an order that is much different to how Tracker wants to order
 things. So many times the position of the poses has to be shuffled. I
 suspect that is part of the issue here. That is also an issue during
 queries of course, as results are returned in whatever order BFS finds
 them in.

 If anyone has other insights, let me know.

-- 
Ticket URL: <https://dev.haiku-os.org/ticket/3011#comment:30>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: