Skip to content

Commit

Permalink
force evalaute js on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
dequanzhu committed Dec 14, 2019
1 parent 01200dc commit 965fc05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HybridPageKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "HybridPageKit"
s.version = "1.3"
s.version = "1.4"
s.summary = "A high-performance、high-extensibility、easy integration framework for Hybrid content page. Support most content page types of News App."
s.homepage = "https://github.com/dequan1331/HybridPageKit"
s.license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion HybridPageKit/HybridPageKit/HybridPageKit/HPKPageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ typedef NS_ENUM (NSInteger, HPKWebViewUAConfigType) {
@param customString 自定义UA字符串
*/
+ (void)configCustomUAWithType:(HPKWebViewUAConfigType)type
UAString:(NSString *)customString;
UAString:(NSString *)customString API_AVAILABLE(ios(9.0));

/**
清除全部的WKWebViewcache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef NS_ENUM (NSInteger, ConfigUAType) {
#pragma mark - UA

+ (void)configCustomUAWithType:(ConfigUAType)type
UAString:(NSString *)customString;
UAString:(NSString *)customString API_AVAILABLE(ios(9.0));

#pragma mark - clear webview cache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ - (void)_safeAsyncEvaluateJavaScriptString:(NSString *)script {
}

- (void)_safeAsyncEvaluateJavaScriptString:(NSString *)script completionBlock:(_HPKWebViewJSCompletionBlock)block {

if(![[NSThread currentThread] isMainThread]){
dispatch_async(dispatch_get_main_queue(), ^{
//retain self
__unused __attribute__((objc_ownership(strong))) __typeof__(self) self_retain_ = self;
[self _safeAsyncEvaluateJavaScriptString:script completionBlock:block];
});
return;
}

if (!script || script.length <= 0) {
HPKErrorLog(@"invalid script");
if (block) {
Expand Down

0 comments on commit 965fc05

Please sign in to comment.