Add OWSJanksUI assertion

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 90dda0bf9c
commit b3cd6a112b

@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (YapDatabaseConnection *)dbReadConnection
{
// OWSAssert(![NSThread isMainThread]);
OWSJanksUI();
// We use TSYapDatabaseObject's dbReadWriteConnection (not OWSPrimaryStorage's
// dbReadConnection) for consistency, since we tend to [TSYapDatabaseObject
@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (YapDatabaseConnection *)dbReadWriteConnection
{
// OWSAssert(![NSThread isMainThread]);
OWSJanksUI();
// Use a dedicated connection for model reads & writes.
static YapDatabaseConnection *dbReadWriteConnection = nil;

@ -150,4 +150,26 @@ void SwiftAssertIsOnMainThread(NSString *functionName);
userInfo:userInfoParam]; \
}
// UI JANK
//
// In pursuit of smooth UI, we want to continue moving blocking operations off the main thread.
// Add `OWSJanksUI` in code paths that shouldn't be called on the main thread.
// Because we have pervasively broken this tenant, enabling it by default would be too disruptive
// but it's helpful while unjanking and maybe someday we can have it enabled by default.
//#define DEBUG_UI_JANK 1
#ifdef DEBUG
#ifdef DEBUG_UI_JANK
#define OWSJanksUI() \
do { \
OWSAssert(![NSThread isMainThread]) \
} while (NO)
#endif
#endif
#ifndef OWSJanksUI
#define OWSJanksUI()
#endif
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save