Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix issue on WKWebView/UIWebView #286

Merged
merged 2 commits into from
Apr 27, 2020

Conversation

paulanatoleclaudot-betclic
Copy link
Contributor

@paulanatoleclaudot-betclic paulanatoleclaudot-betclic commented Apr 17, 2020

Sometimes and for unknown reason, WKWebview/UIWebView calls skeletonLayoutSubviews not on the main thread, which causing NSISEngine to crash

Fatal Exception:
NSInternalInconsistencyException Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.

Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x18d17096c __exceptionPreprocess
1 libobjc.A.dylib 0x18ce89028 objc_exception_throw
2 Foundation 0x18d65c5e0 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints]
3 Foundation 0x18d455854 -[NSISEngine _optimizeWithoutRebuilding]
4 Foundation 0x18d455768 -[NSISEngine optimize]
5 Foundation 0x18d4553d8 -[NSISEngine performPendingChangeNotifications]
6 UIKitCore 0x1917115b8 -[UIView(Hierarchy) layoutSubviews]
7 SkeletonView 0x1018458d4 @objc UIView.skeletonLayoutSubviews() + 98 (SkeletonView.swift:98)

Crashed: WebThread
SIGABRT ABORT 0x000000018cf5aefc

@paulanatoleclaudot-betclic paulanatoleclaudot-betclic changed the title [BugFix] Fix issue on WKWebView [BugFix] Fix issue on WKWebView/UIWebView Apr 17, 2020
@@ -94,6 +94,7 @@ public extension UIView {

extension UIView {
@objc func skeletonLayoutSubviews() {
guard Thread.isMainThread else { return }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this guard should be after the skeletonLayoutSubviews method. Here, the original layoutSubviews method will not be called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stacktrace shows us that the issue came from the skeletonLayoutSubviews. We should "kill" it as soon as possible, so in the first call (not in the child view, which gonna have the same thread issue), what do you think ?
In any case, this should not be called on another thread but the main one.

@Juanpe Juanpe merged commit 0b5d618 into Juanpe:develop Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants