forkingdog / forkingdog/FDStackView

Crash in iOS 8 when remove a view from UIStackView

未关闭
#35 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Objective-C
星标
2.5k
派生
310
PR 合并指标
30 天内没有已合并 PR

描述

状况如下:
1. iOS 8 模拟器
2. StoryBoard 布局好了,一个StackView上有3个等长Button
3. 在ViewController viewDidLoad/viewDidAppear 时,将一个按钮 removeFromSuperView
崩溃~
iOS 9下没问题~

以下Log

> 2016-06-21 15:40:41.868 Mingdao[73952:20315626] The view hierarchy is not prepared for the constraint:
> When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
> 2016-06-21 15:40:41.868 Mingdao[73952:20315626] **\* Assertion failure in -[UIStackView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/NSLayoutConstraint_UIKitAdditions.m:560
> 2016-06-21 15:40:41.881 Mingdao[73952:20315626] **\* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
> **\* First throw call stack:
> (
> 0 CoreFoundation 0x01498746 __exceptionPreprocess + 182
> 1 libobjc.A.dylib 0x04524a97 objc_exception_throw + 44
> 2 CoreFoundation 0x014985da +[NSException raise:format:arguments:] + 138
> 3 Foundation 0x01f75720 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
> 4 UIKit 0x032f22c1 __120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2 + 203
> 5 UIKit 0x032f2184 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 394
> 6 UIKit 0x032f2507 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 61
> 7 UIKit 0x032f265c -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 281
> 8 UIKit 0x032f2854 -[UIView(UIConstraintBasedLayout) nsli_addConstraint:] + 56
> 9 UIKit 0x032f2814 -[UIView(UIConstraintBasedLayout) _addConstraint:] + 218
> 10 UIKit 0x032f2735 -[UIView(UIConstraintBasedLayout) addConstraint:] + 40
> 11 Mingdao 0x005555a0 -[FDStackViewDistributionLayoutArrangement resetFillEffect] + 1632
> 12 Mingdao 0x00557589 -[FDStackViewDistributionLayoutArrangement resetAllConstraints] + 73
> 13 Mingdao 0x00557b3d -[FDStackViewDistributionLayoutArrangement updateCanvasConnectionConstraintsIfNecessary] + 45
> 14 Mingdao 0x0055893d -[FDStackViewLayoutArrangement updateArrangementConstraints] + 45
> 15 Mingdao 0x0055076d -[FDStackView updateLayoutArrangements] + 221
> 16 Mingdao 0x00550800 -[FDStackView updateConstraints] + 48
> 17 UIKit 0x032ff5a4 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 300
> 18 UIKit 0x032ff804 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
> 19 UIKit 0x032ff77f __UIViewRecursionHelper + 41
> 20 CoreFoundation 0x0138b529 CFArrayApplyFunction + 57
> 21 UIKit 0x032ff527 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 175
> 22 UIKit 0x032ff804 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
> 23 UIKit 0x032ff77f __UIViewRecursionHelper + 41
> 24 CoreFoundation 0x0138b529 CFArrayApplyFunction + 57
> 25 UIKit 0x032ff527 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 175
> 26 UIKit 0x032ff837 __125-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:]_block_invoke + 43
> 27 Foundation 0x01ef1077 -[NSISEngine withBehaviors:performModifications:] + 150
> 28 Foundation 0x01ef45cf -[NSISEngine withAutomaticOptimizationDisabled:] + 48
> 29 UIKit 0x032fefab -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 64
> 30 UIKit 0x032ff804 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 127
> 31 UIKit 0x032ffd96 __60-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]_block_invoke + 105
> 32 Foundation 0x01ef1077 -[NSISEngine withBehaviors:performModifications:] + 150
> 33 Foundation 0x01ef45cf -[NSISEngine withAutomaticOptimizationDisabled:] + 48
> 34 UIKit 0x032fefab -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 64
> 35 UIKit 0x032ff9ec -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 248
> 36 UIKit 0x0330024d -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 191
> 37 UIKit 0x02c0adaf -[UIView(Hierarchy) layoutBelowIfNeeded] + 393
> 38 UIKit 0x02c0ac11 -[UIView(Hierarchy) layoutIfNeeded] + 83
> 39 UIKit 0x02d22bc5 -[UINavigationController _layoutViewController:] + 1154
> 40 UIKit 0x02d21d41 -[UINavigationController _layoutTopViewController] + 261
> 41 UIKit 0x02d26fd9 -[UINavigationController _tabBarControllerDidFinishShowingTabBar:isHidden:] + 164
> 42 UIKit 0x02d377d0 -[UITabBarController animationDidStop:finished:context:] + 218
> 43 UIKit 0x02d38771 __56-[UITabBarController _hideBarWithTransition:isExplicit:]_block_invoke503 + 267
> 44 UIKit 0x033f3f0b -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 198
> 45 UIKit 0x033f05c0 -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 122
> 46 UIKit 0x033f02dc -[_UIViewControllerTransitionContext completeTransition:] + 142
> 47 UIKit 0x02b73310 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke93 + 724
> 48 UIKit 0x02c1096e -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 318
> 49 UIKit 0x02bf4162 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 206
> 50 UIKit 0x02bf44d2 -[UIViewAnimationState animationDidStop:finished:] + 80
> 51 QuartzCore 0x02907571 _ZN2CA5Layer23run_animation_callbacksEPv + 307
> 52 libdispatch.dylib 0x0574ebef _dispatch_client_callout + 14
> 53 libdispatch.dylib 0x057346bb _dispatch_main_queue_callback_4CF + 993
> 54 CoreFoundation 0x013f18ee __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
> 55 CoreFoundation 0x013af5f0 __CFRunLoopRun + 2256
> 56 CoreFoundation 0x013aea5b CFRunLoopRunSpecific + 443
> 57 CoreFoundation 0x013ae88b CFRunLoopRunInMode + 123
> 58 GraphicsServices 0x076342c9 GSEventRunModal + 192
> 59 GraphicsServices 0x07634106 GSEventRun + 104
> 60 UIKit 0x02b860b6 UIApplicationMain + 1526
> 61 Mingdao 0x002c86aa main + 138
> 62 libdyld.dylib 0x05779ac9 start + 1
> 63 ??? 0x00000001 0x0 + 1
> )
> libc++abi.dylib: terminating with uncaught exception of type NSException

贡献指南

这个仓库没有索引到贡献指南

调研方向

使用包含三个按钮的 storyboard UIStackView,在 iOS 8 模拟器中重现该报告,然后从 FDStackView.updateConstraints 经过 FDStackViewLayoutArrangement 追踪到 FDStackViewDistributionLayoutArrangement。检查 resetFillEffect、resetAllConstraints 和 updateCanvasConnectionConstraintsIfNecessary;完成的标准是,在 iOS 8 上移除一个按钮时不再在布局过程中崩溃,同时 iOS 9 的行为不受影响。

由索引模型根据 Issue 内容生成。

评估

技术栈
ios, objective-c
领域
mobile-dev
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。