Closed wutschel closed 2 years ago
reloadData must be called only from the main thread
I need to correct myself. The function which possibly concurs is called via a timer. Is a timer spawning a worker thread well?
Timer callback is called on the thread which you schedule the timer on
Thanks, then this is main thread.
Do I still need to use dispatch_sync
to avoid that beginUpdates
/ endUpdates
is interrupted by reloadData
when all calls come from the main thread?
Do I still need to use
dispatch_sync
to avoid thatbeginUpdates
/endUpdates
is interrupted byreloadData
when all calls come from the main thread?
sorry, missed your question. If you attempt to execute
dispatch_sync(dispatch_get_main_queue(), ^{ ... });
on main thread, you'll get into deadlock.
From a comment by @kambala-decapitator it is per documentation not allowed to call
reloadData
betweenbeginUpdates
/endUpdate
. In the App's code this might happen when the worker thread which updates the information for the visible channels is concurring with the updates trigger from the main thread. Choices to fix this is either usingdispatch_sync
to serialize any such event, or simply usingreloadData
. The latter will not only update the visible entries of the channel list, but all of them.The
reloadData
solution (https://github.com/xbmc/Official-Kodi-Remote-iOS/compare/master...wutschel:fix_channelupdate):reloadData
thread-safe?The
dispatch_sync
solution would require eachreloadData
call insideDetailViewController
to be encapsulated withdispatch_sync
. In this case I would introduce helper methods for this.