diff --git a/SignalMessaging/Views/CVText.swift b/SignalMessaging/Views/CVText.swift index fbe38c9cc9..bbd2589dd3 100644 --- a/SignalMessaging/Views/CVText.swift +++ b/SignalMessaging/Views/CVText.swift @@ -370,9 +370,17 @@ public class CVText { textStorage.addLayoutManager(layoutManager) - layoutManager.glyphRange(for: textContainer) let size = layoutManager.usedRect(for: textContainer).size + // For some reason, in production builds, the textStorage + // seems to get optimized out in many circumstances. This + // results in `usedRect` measuring an empty string and a + // size of 0,0. + // TODO: Figure out a better way to fix this. For now, + // by just using the textStorage later it ensures that it + // is properly measured. + _ = textStorage + return size.ceil } @@ -492,9 +500,17 @@ public class CVText { textStorage.addLayoutManager(layoutManager) - layoutManager.glyphRange(for: textContainer) let size = layoutManager.usedRect(for: textContainer).size + // For some reason, in production builds, the textStorage + // seems to get optimized out in many circumstances. This + // results in `usedRect` measuring an empty string and a + // size of 0,0. + // TODO: Figure out a better way to fix this. For now, + // by just using the textStorage later it ensures that it + // is properly measured. + _ = textStorage + return size.ceil }