ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.84k stars 1.67k forks source link

[fix]: blocking system assertions #990

Open zColdWater opened 8 months ago

zColdWater commented 8 months ago

iOS 17 会在 debug 模式下 走到系统断言

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={337, 0}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.' First throw call stack: (0x1a910c870 0x1a140bc00 0x1a8676e54 0x1ab338380 0x11b2454d8 0x11b244d6c 0x1aa68be54 0x1aa692278 0x1aa68b574 0x1ab2ee970 0x1ab2ee468 0x1ab2edb58 0x1ab2edc14 0x1a905731c 0x1a9056598 0x1a9054d4c 0x1a9053a88 0x1a9053668 0x1ec41e5ec 0x1ab470294 0x1ab46f8d0 0x102bbc2f0 0x1cbaa6dcc) libc++abi: terminating due to uncaught exception of type NSException *** Assertion failure in void _UIGraphicsBeginImageContextWithOptions(CGSize, BOOL, CGFloat, BOOL)(), UIGraphics.m:410

临时方案,阻止断言的触发 如果可能,使用 UIGraphicsImageRenderer 替代 UIGraphicsBeginImageContext(),因为它能更好地处理这种情况。