使用web view 与native 进行交互的时候 出现了
如下警告:并且跳转会有延迟。
警告如下:
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x0000000181849918 <redacted> + 148
1 libobjc.A.dylib 0x0000000180eb7f80 objc_exception_throw + 56
2 CoreFoundation 0x0000000181849848 <redacted> + 0
3 Foundation 0x00000001822e72d4 <redacted> + 88
4 Foundation 0x000000018216d99c <redacted> + 56
5 Foundation 0x0000000182174fb4 <redacted> + 1036
6 Foundation 0x00000001821749d8 <redacted> + 240
7 UIKit 0x0000000186646e90 <redacted> + 176
8 UIKit 0x0000000186647384 <redacted> + 196
9 UIKit 0x00000001866423f4 <redacted> + 268
10 UIKit 0x0000000186598db0 <redacted> + 80
11 UIKit 0x00000001865436c4 <redacted> + 572
12 UIKit 0x00000001867d5ca4 <redacted> + 1384
13 UIKit 0x000000018654a964 <redacted> + 80
14 UIKit 0x0000000186735118 <redacted> + 260
15 UIKit 0x0000000186850840 <redacted> + 220
16 UIKit 0x0000000186734c90 <redacted> + 1060
17 UIKit 0x00000001866ee6a0 <redacted> + 3544
18 UIKit 0x00000001865fa9b8 <redacted> + 688
19 UIKit 0x00000001865fa694 <redacted> + 60
20 UIKit 0x00000001865fa5fc <redacted> + 208
21 UIKit 0x0000000186537778 <redacted> + 656
22 QuartzCore 0x0000000183f46b2c <redacted> + 148
23 QuartzCore 0x0000000183f41738 <redacted> + 292
24 QuartzCore 0x0000000183f415f8 <redacted> + 32
25 QuartzCore 0x0000000183f40c94 <redacted> + 252
26 QuartzCore 0x0000000183f409dc <redacted> + 512
27 QuartzCore 0x0000000183f3a0cc <redacted> + 80
28 CoreFoundation 0x0000000181800588 <redacted> + 32
29 CoreFoundation 0x00000001817fe32c <redacted> + 372
30 CoreFoundation 0x000000018172d6a0 CFRunLoopRunSpecific + 416
31 WebCore 0x00000001852dd738 <redacted> + 456
32 libsystem_pthread.dylib 0x00000001814b3b28 <redacted> + 156
33 libsystem_pthread.dylib 0x00000001814b3a8c <redacted> + 0
34 libsystem_pthread.dylib 0x00000001814b1028 thread_start + 4
Stack:(
0 CoreFoundation 0x0000000181849918 <redacted> + 148
1 libobjc.A.dylib 0x0000000180eb7f80 objc_exception_throw + 56
2 CoreFoundation 0x0000000181849848 <redacted> + 0
3 Foundation 0x00000001822e72d4 <redacted> + 88
4 Foundation 0x000000018216d99c <redacted> + 56
5 Foundation 0x0000000182174fb4 <redacted> + 1036
6 Foundation 0x00000001821749d8 <redacted> + 240
7 UIKit 0x0000000186646e90 <redacted> + 176
8 UIKit 0x0000000186647384 <redacted> + 196
9 UIKit 0x00000001866423f4 <redacted> + 268
10 UIKit 0x0000000186598db0 <redacted> + 80
11 UIKit 0x00000001865436c4 <redacted> + 572
12 UIKit 0x00000001867d5ca4 <redacted> + 1384
13 UIKit 0x000000018654a964 <redacted> + 80
14 UIKit 0x0000000186735118 <redacted> + 260
15 UIKit 0x0000000186850840 <redacted> + 220
16 UIKit 0x0000000186734c90 <redacted> + 1060
17 UIKit 0x00000001866ee6a0 <redacted> + 3544
18 UIKit 0x00000001865fa9b8 <redacted> + 688
19 UIKit 0x00000001865fa694 <redacted> + 60
20 UIKit 0x00000001865fa5fc <redacted> + 208
21 UIKit 0x0000000186537778 <redacted> + 656
22 QuartzCore 0x0000000183f46b2c <redacted> + 148
23 QuartzCore 0x0000000183f41738 <redacted> + 292
24 QuartzCore 0x0000000183f415f8 <redacted> + 32
25 QuartzCore 0x0000000183f40c94 <redacted> + 252
26 QuartzCore 0x0000000183f409dc <redacted> + 512
27 QuartzCore 0x0000000183f3a0cc <redacted> + 80
28 CoreFoundation 0x0000000181800588 <redacted> + 32
29 CoreFoundation 0x00000001817fe32c <redacted> + 372
30 CoreFoundation 0x000000018172d6a0 CFRunLoopRunSpecific + 416
31 WebCore 0x00000001852dd738 <redacted> + 456
32 libsystem_pthread.dylib 0x00000001814b3b28 <redacted> + 156
33 libsystem_pthread.dylib 0x00000001814b3a8c <redacted> + 0
34 libsystem_pthread.dylib 0x00000001814b1028 thread_start + 4
)
解决方案是: 进行跳转到原生页面 把这段代码加到主线程 然后就不会出现这种问题了。
It needs to be placed inside a different thread that allows the UI to update:
dispatch_async(dispatch_get_main_queue(), ^{
// code here
// code here
});