Fix a bug which happens when web view fail to load. Replace run loop with dispatch semaphore.