             loadSqlDb()
         }
 
-        runtimeDebugOnlyTestVerifyResourcesLoaded()
-
-        if domainToIdMapping != nil && db != nil {
-            NSNotificationCenter.defaultCenter().postNotificationName(HttpsEverywhere.kNotificationDataLoaded, object: self)
-            runtimeDebugOnlyTestDomainsRedirected()
+        delay(0) { // runs the closure on main thread
+            self.runtimeDebugOnlyTestVerifyResourcesLoaded()
+
+            if self.domainToIdMapping != nil && self.db != nil {
+                NSNotificationCenter.defaultCenter().postNotificationName(HttpsEverywhere.kNotificationDataLoaded, object: self)
+                self.runtimeDebugOnlyTestDomainsRedirected()
+            }
         }
     }
 

                return nil
            }
        }


        return newUrl
    }

                    return
                }
            }

            let url = HttpsEverywhere.singleton.tryRedirectingUrl(NSURL(string: "http://www.googleadservices.com/pagead/aclk?sa=L&ai=CD0d")!)
            if url == nil || !url!.absoluteString.hasSuffix("?sa=L&ai=CD0d") {
                BraveApp.showErrorAlert(title: "Debug Error", error: "HTTPS-E validation failed for url args")
            }
        }
#endif
    }
