Opened 14 years ago

Closed 14 years ago

#391 closed Enhancement (Fixed)

defer setting scrollTop in JVStyleView

Reported by: stephen.butler@… Owned by: timothy
Component: Colloquy (Mac) Version: 2.2 (Mac)
Severity: Normal Keywords:
Cc:

Description

Adding many lines at once to a JVStyleView can be slow. This is especially the case when the scrollback buffer is set fairly low and messages are being removed from the top. After spending some time with Shark and a simple test case, around 30% of the time was being spent on calls such as [_body setValue:<#x#> forKey:@"scrollTop"].

This patch delays such calls until the run loop enters an idle state. Shark post-analysis shows a dramatic increase. A test case that used to run in 14s now runs in 7s. Where the application used to spend 30% of its time in calls like scrollToBottom, it now spends less than 10%.

There are two hidden preferences that keep a single window from starving others:

1) JVChatScrollTopTimeThreshold: if the difference between consecutive _setScrollTop calls is at least this many seconds then the scrolling happen immediately. If another window is hogging the run loop then a slower updating window will not be affected. Default: 0.5 seconds.

2) JVChatScrollTopDeferedThreshold: the maximum number of defered _setScrollTop calls before an immediately _setScrollTop is forced. Default: 1000.

Side Effects: the code to enforce scrollback buffer limiting has been moved into the setScrollTop call. This makes sense since scrollback limiting affects the scroll top position, and the functions that previously did scrollback limiting call _setScrollTop in most cases anyway. But if a user has scrolled up from the bottom then the scrollback limiting is not enforced until a new message is added after they return to the bottom. Personally, I rather like this behavior, as it lets me view previous messages without worrying about losing them.

Patch and test case attached.

Change History (1)

comment:1 Changed 14 years ago by timothy

  • Resolution set to fixed
  • Status changed from new to closed

Landed this patch in [3055]. Thanks Stephen and sorry for the delay.

Note: See TracTickets for help on using tickets.