{"action":"created","issue":{"url":"https://api.github.com/repos/Babylonpartners/Bento/issues/78","repository_url":"https://api.github.com/repos/Babylonpartners/Bento","labels_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/78/comments","events_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/78/events","html_url":"https://github.com/Babylonpartners/Bento/pull/78","id":383054030,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyNjEyNTg5","number":78,"title":"Fix possible autolayout loop when using an ImageOrLabel/TitledDescription component in a section header","user":{"login":"Ben-Henshall","id":15949658,"node_id":"MDQ6VXNlcjE1OTQ5NjU4","avatar_url":"https://avatars0.githubusercontent.com/u/15949658?v=4","gravatar_id":"","url":"https://api.github.com/users/Ben-Henshall","html_url":"https://github.com/Ben-Henshall","followers_url":"https://api.github.com/users/Ben-Henshall/followers","following_url":"https://api.github.com/users/Ben-Henshall/following{/other_user}","gists_url":"https://api.github.com/users/Ben-Henshall/gists{/gist_id}","starred_url":"https://api.github.com/users/Ben-Henshall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ben-Henshall/subscriptions","organizations_url":"https://api.github.com/users/Ben-Henshall/orgs","repos_url":"https://api.github.com/users/Ben-Henshall/repos","events_url":"https://api.github.com/users/Ben-Henshall/events{/privacy}","received_events_url":"https://api.github.com/users/Ben-Henshall/received_events","type":"User","site_admin":false},"labels":[{"id":822373940,"node_id":"MDU6TGFiZWw4MjIzNzM5NDA=","url":"https://api.github.com/repos/Babylonpartners/Bento/labels/DO%20NOT%20MERGE","name":"DO NOT MERGE","color":"000000","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-11-21T10:33:52Z","updated_at":"2018-11-21T12:01:20Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/Babylonpartners/Bento/pulls/78","html_url":"https://github.com/Babylonpartners/Bento/pull/78","diff_url":"https://github.com/Babylonpartners/Bento/pull/78.diff","patch_url":"https://github.com/Babylonpartners/Bento/pull/78.patch"},"body":"This PR fixes an issue where some (very specific) scenarios would create an autolayout loop and freeze the app.\r\n\r\nFrom what I understand of the loop, it appears to be caused by `ImageOrLabelView` extending outside of the safe area. This triggers a resize of the imageOrLabelView, which causes a hierarchy-wide reshuffle. This loops infinitely and causes any application to lock.\r\n\r\nHere is the debug output from the `UIViewLayoutFeedbackLoopDebuggingThreshold` launch argument:\r\n```\r\n2018-11-19 11:39:05.213382+0000 Babylon[74990:14118052] [LayoutLoop] Degenerate layout! Layout feedback loop detected in subtree of <_UITableViewHeaderFooterContentView: 0x11fd36270; frame = (0 0; 375 64); wants auto layout; hosts layout engine; tAMIC = YES; >. \r\n\r\nTop-level view = <_UITableViewHeaderFooterContentView: 0x11fd36270; frame = (0 0; 375 64); wants auto layout; hosts layout engine; tAMIC = YES; >\r\n\r\nViews caught in loop: \r\n8 <_UITableViewHeaderFooterContentView: 0x11fd36270; frame = (0 0; 375 64); wants auto layout; hosts layout engine; tAMIC = YES; >\r\n|   1 <TitledDescriptionView: 0x11fd36630; frame = (0 0; 375 64); wants auto layout; tAMIC = NO; >\r\n|   |   4 <BentoKit.BaseStackView: 0x11fd368e0; baseClass = UIStackView; frame = (16 32; 343 24); wants auto layout; tAMIC = NO; >\r\n|   |   |   <UIView: 0x11d3687e0; frame = (0 0; 343 24); wants auto layout; tAMIC = NO; >\r\n|   |   |   5 <BentoKit.ImageOrLabelView: 0x11fd36b00; frame = (0 2; 0 20.5); wants auto layout; tAMIC = NO; >\r\n|   |   |   |   7 <UILabel: 0x11fd36d20; frame = (0 0; 0 8.5); wants auto layout; tAMIC = NO; >\r\n|   |   |   |   6 <UIImageView: 0x11d366820; frame = (0 0; 0 0); wants auto layout; tAMIC = NO; >\r\n|   |   |   <UIStackView: 0x11d367980; frame = (0 0; 343 24); wants auto layout; tAMIC = NO; >\r\n|   |   |   |   <UILabel: 0x11d3673a0; frame = (0 0; 58 24); text = 'About'; wants auto layout; tAMIC = NO; >\r\n|   |   |   |   <UILabel: 0x11d367690; frame = (0 24; 0 0); wants auto layout; tAMIC = NO; >\r\n|   |   |   <UILabel: 0x11d366a50; frame = (343 12; 0 0); wants auto layout; tAMIC = NO; >\r\n|   |   |   <BentoKit.AccessoryView: 0x11d367170; frame = (343 0; 24 24); wants auto layout; tAMIC = NO; >\r\n|   |   2 <_TtCCCO8BentoKit9Component17TitledDescription4ViewP33_EE75C7FE6017E49AEF71599B5636213E9BadgeView: 0x11d366d40; frame = (10 48.5; 12 12); wants auto layout; tAMIC = NO; >\r\n|   |   |   3 <UIImageView: 0x11d366f40; frame = (0 0; 12 12); wants auto layout; tAMIC = NO; >\r\n\r\nViews receiving layout in order: (\r\n\t<TitledDescriptionView: 0x11fd36630; frame = (0 0; 375 64); wants auto layout; tAMIC = NO; >\r\n\t<_TtCCCO8BentoKit9Component17TitledDescription4ViewP33_EE75C7FE6017E49AEF71599B5636213E9BadgeView: 0x11d366d40; frame = (10 48.5; 12 12); wants auto layout; tAMIC = NO; >\r\n\t<UIImageView: 0x11d366f40; frame = (0 0; 12 12); wants auto layout; tAMIC = NO; >\r\n\t<BentoKit.BaseStackView: 0x11fd368e0; baseClass = UIStackView; frame = (16 32; 343 24); wants auto layout; tAMIC = NO; >\r\n\t<BentoKit.ImageOrLabelView: 0x11fd36b00; frame = (0 2; 0 20.5); wants auto layout; tAMIC = NO; >\r\n\t<UIImageView: 0x11d366820; frame = (0 0; 0 0); wants auto layout; tAMIC = NO; >\r\n\t<UILabel: 0x11fd36d20; frame = (0 0; 0 8.5); wants auto layout; tAMIC = NO; >\r\n\t<_UITableViewHeaderFooterContentView: 0x11fd36270; frame = (0 0; 375 64); wants auto layout; hosts layout engine; tAMIC = YES; >\r\n)\r\n```\r\n\r\nTo prevent `imageOrLabelView` from resizing (which is done because its margins extend outside of the safe area) we can change `insetsLayoutMarginsFromSafeArea` which leaves the margins as they are if we extend out of the safe area."},"comment":{"url":"https://api.github.com/repos/Babylonpartners/Bento/issues/comments/440639067","html_url":"https://github.com/Babylonpartners/Bento/pull/78#issuecomment-440639067","issue_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/78","id":440639067,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDYzOTA2Nw==","user":{"login":"Ben-Henshall","id":15949658,"node_id":"MDQ6VXNlcjE1OTQ5NjU4","avatar_url":"https://avatars0.githubusercontent.com/u/15949658?v=4","gravatar_id":"","url":"https://api.github.com/users/Ben-Henshall","html_url":"https://github.com/Ben-Henshall","followers_url":"https://api.github.com/users/Ben-Henshall/followers","following_url":"https://api.github.com/users/Ben-Henshall/following{/other_user}","gists_url":"https://api.github.com/users/Ben-Henshall/gists{/gist_id}","starred_url":"https://api.github.com/users/Ben-Henshall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ben-Henshall/subscriptions","organizations_url":"https://api.github.com/users/Ben-Henshall/orgs","repos_url":"https://api.github.com/users/Ben-Henshall/repos","events_url":"https://api.github.com/users/Ben-Henshall/events{/privacy}","received_events_url":"https://api.github.com/users/Ben-Henshall/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T12:01:20Z","updated_at":"2018-11-21T12:01:20Z","author_association":"NONE","body":"I've tried it out in `Babylon` and it seems to cause a couple more auto layout loops. The main suspect is `preservesSuperviewLayoutMargins`. Should we make `ImageOrLabelView` a `BaseView` and explicitly change `preservesSuperviewLayoutMargins`, or just add set `insetsLayoutMarginsFromSafeArea` as seen in this PR currently?"}}
{"actor":{"display_login":"Ben-Henshall"}}