Opened 5 years ago

Closed 5 years ago

#3194 closed Defect (Fixed)

_switchStyle yields excessively to run loop while populating view

Reported by: jalkut@… Owned by: timothy
Component: Colloquy (Mac) Version: Local Build
Severity: Normal Keywords:
Cc:

Description

For years I've noticed when I "/reload style" or open a transcript, Colloquy struggles to populate the view with the pages and pages of messages that may be included in the conversation.

I assumed it was some complex rendering issue with the WebView?, but today I finally took a look and discovered it's a case of the thread responsible for loading the view volunteering 1-second delays at every iteration through the load loop:

[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.]]; give time to other threads

I believe it's doing this once every 25 lines, so you can imagine how a 250 line backlog will take 10 seconds, a 2500 line backlog 100 seconds, etc.

Now, the current comment for the second-long sleep is vague: "give time to other threads." It doesn't make complete sense because other threads should be getting time ... how much time to do they need? Anyway, usually a user-facing action like loading of content is a good thing to prioritize. To find the original intentions for the thread-sleeping, I went back to revision 1853:

1853 timothy usleep( 100000 ); wait for WebKit? to render the chunk

The commit message for r1853 is:

r1853 | timothy | 2004-09-12 14:58:36 -0400 (Sun, 12 Sep 2004) | 2 lines
No more blank chat area, this is a temp fix. Curse you WebView?...

So I believe this was a crude workaround for a bug back in 2004, and is either no longer necessary, or can probably at least be alleviated so it doesn't yield quite so much time. On my Mac, simply deleting the causes no obvious "blank screen" in reloading style or loading transcripts, and best of all, the content loads nearly instantly.

So my proposed fix is simply to delete the sleep line.

Change History (1)

comment:1 Changed 5 years ago by zach

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

Committed in r5527, thank you!

Note: See TracTickets for help on using tickets.