signalapp / Signal-iOS

A private messenger for iOS.
https://signal.org
GNU Affero General Public License v3.0
10.78k stars 3.02k forks source link

Fix for constraint SafeArea loop crash. #5703

Open johnsonajason opened 10 months ago

johnsonajason commented 10 months ago

First time contributor checklist

Contributor checklist

Description

This is to fix a crash that occurs on specific devices in landscape. There was an edge case issue with constraints and safeArea causing the views layout to loop and eventually crash.

Steps to reproduce the crash:

The share sheet will not present and memory will constantly grow. The app will eventually crash.

To Verify the reason for the crash you can add -UIViewLayoutFeedbackLoopDebuggingThreshold 50 to the apps run arguments and set an all exceptions breakpoint with the following action po [_UIViewLayoutFeedbackLoopDebugger layoutFeedbackLoopDebugger]

Issue: The constraints on the actionSheets scrollView subviews would adjust to to avoid the safeArea, this in turn would resize the scrollview. In most cases this works correctly but if the size of the subview was within a small range of the maximum scrollView size a constraint loop would occur where resizing the scrollView would relayout the subviews which would no longer be affected by the safeArea causing the scrollView to resize again. This would continue to infinitely resize these views in a layout loop.

Solution: To solve this issue I moved the handling of the safeArea to the scrollView and altered a few layout parameters to compensate for this change.

Miguel-Signal commented 8 months ago

Hi @johnsonajason, thanks for bringing this crash to our attention.

I've gone ahead and filed this with our engineering team. While our engineers are working on a fix, I unfortunately can't give out a specific timeline for a resolution.