# Slow rendering on El Capitan solution

**URL:** <https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292>\
**Category:** General\
**Created:** [November 25, 2015, 8:53pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292 "2015-11-25T20:53:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim\_mckay](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_mckay/32/905_2.png) [@jim\_mckay](https://forum.xojo.com/u/jim_mckay)\
**Post date:** [November 25, 2015, 8:53pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/1 "2015-11-25T20:53:44Z")

</div>

Hi all. I put together a module that defers invalidate calls to avoid some issues El Capitan introduced (timers causing excessive redraws). Try it out. It’s free.

To use it, just add the module to a project, then replace calls to control.invalidate and window.invalidate with control.invalidateDeferred and window.invalidateDeferred.

It essentially makes a list of objects needing to be invalidated and then invalidates them all at once from a timer.

One side effect is that it can be called from a thread without issue.

Another side effect is that it solves the same issue on Linux. (go figure)

Here it is [http://www.pidog.com/share/DeferredInvalidate.xojo\_binary\_project.zip](http://www.pidog.com/share/DeferredInvalidate.xojo_binary_project.zip)

Post any results (good or bad)!  
I’d like to know if it causes any issues I didn’t foresee.

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [November 25, 2015, 8:57pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/2 "2015-11-25T20:57:30Z")

</div>

It still seems like a bad idea to have such a high resolution timer and having it invalidate the UI…

---

<div class="post-metadata">

**Author:** ![jim\_mckay](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_mckay/32/905_2.png) [@jim\_mckay](https://forum.xojo.com/u/jim_mckay)\
**Post date:** [November 25, 2015, 9:02pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/3 "2015-11-25T21:02:27Z")

</div>

Well, in the example, I have a high resolution timer to test the ability to defer the redraws. In reality there could be any number of functions/events that need to update the UI going on that may overlap, and any timer firing would cause the UI to redraw and drag everything to a crawl. This just takes UI updates out of the hands of unrelated code.

---

<div class="post-metadata">

**Author:** ![James\_Sentman](https://forum.xojo.com/user_avatar/forum.xojo.com/james_sentman/32/742_2.png) [@James\_Sentman](https://forum.xojo.com/u/James_Sentman)\
**Post date:** [November 25, 2015, 9:29pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/4 "2015-11-25T21:29:51Z")

</div>

is there an issue with timers causing refreshes on ElCapitan? Even if they dont actually call refresh or invalidate? I would like to know more about that if thats the case!

---

<div class="post-metadata">

**Author:** ![Marco\_Hof](https://forum.xojo.com/user_avatar/forum.xojo.com/marco_hof/32/642_2.png) [@Marco\_Hof](https://forum.xojo.com/u/Marco_Hof)\
**Post date:** [November 25, 2015, 9:43pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/5 "2015-11-25T21:43:17Z")

</div>

@James: See [https://forum.xojo.com/27651-graphics-slow-on-el-capitan/p2#p229054](https://forum.xojo.com/27651-graphics-slow-on-el-capitan/p2#p229054)

---

<div class="post-metadata">

**Author:** ![James\_Sentman](https://forum.xojo.com/user_avatar/forum.xojo.com/james_sentman/32/742_2.png) [@James\_Sentman](https://forum.xojo.com/u/James_Sentman)\
**Post date:** [November 27, 2015, 5:19pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/6 "2015-11-27T17:19:58Z")

</div>

AH, I think I get it now. Thank you. Having a timer doesnt cause a refresh unless there are invalidated regions outstanding and then they will be redrawn when the timer fires even if it had nothing to do with them. As falling into the run loop causes anything invalidated to be redrawn. That seems wrong to me from a logic standpoint but maybe I dont understand the reasoning or what it was supposed to fix in the first place…

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [November 29, 2015, 4:06pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/7 "2015-11-29T16:06:31Z")

</div>

Seems very wrong indeed. Maybe Joe can enlighten us 

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [November 30, 2015, 12:34am UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/8 "2015-11-30T00:34:06Z")

</div>

> [@232383:@James Sentman](#):
>
> AH, I think I get it now. Thank you. Having a timer doesnt cause a refresh unless there are invalidated regions outstanding and then they will be redrawn when the timer fires even if it had nothing to do with them. As falling into the run loop causes anything invalidated to be redrawn. That seems wrong to me from a logic standpoint but maybe I dont understand the reasoning or what it was supposed to fix in the first place…

This is a correct summary. My understanding is that this is Apple’s approach to unifying AppKit and Core Animation’s layout and drawing cycles. An application can make all of the invalidations or animations they want during event processing and everything will get processed at the very end of the event loop in one go.

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 30, 2015, 1:35pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/9 "2015-11-30T13:35:43Z")

</div>

> [@](#):
>
> An application can make all of the invalidations or animations they want during event processing and everything will get processed at the very end of the event loop in one go.

Doesnt that lead to jerky animation and screen artefacts?  
Surely this is a retrograde step?

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [November 30, 2015, 3:52pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/10 "2015-11-30T15:52:52Z")

</div>

> [@232921:@Jeff Tullin](#):
>
> Doesnt that lead to jerky animation and screen artefacts?

Nope.

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [December 1, 2015, 3:23am UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/11 "2015-12-01T03:23:14Z")

</div>

[quote=232921:@Jeff Tullin]Doesnt that lead to jerky animation and screen artefacts?  
Surely this is a retrograde step?[/quote]  
A standard application event loop is very very quick, much quicker than you would imagine. I don’t quite know how to explain it, but it’s not loop that you would create in Xojo code.

---

<div class="post-metadata">

**Author:** ![James\_Sentman](https://forum.xojo.com/user_avatar/forum.xojo.com/james_sentman/32/742_2.png) [@James\_Sentman](https://forum.xojo.com/u/James_Sentman)\
**Post date:** [December 1, 2015, 2:03pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/12 "2015-12-01T14:03:14Z")

</div>

I keep failing to wrap my head around how this will affect things though, I keep coming back that it should be fine under almost any normal circumstances. But I realize that I dont really know what Im comparing it against. How did it previously decide how to start a redraw?

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:04pm UTC](https://forum.xojo.com/t/slow-rendering-on-el-capitan-solution/28292/13 "2020-10-29T18:04:33Z")

</div>


