Closed wangzhizhou closed 5 months ago
Hi, thanks for reporting this issue.
Looking at the crash indicates that the context bitmap has size {0,0}
:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:'
UIGraphicsBeginImageContext() failed to allocate CGBitampContext:
size={0, 0},
scale=1.000000,
bitmapInfo=0x2002.
Use UIGraphicsImageRenderer to avoid this assert.'
I believe that simply using the UIGraphicsImageRenderer
is not a valid solution, because it basically just avoids the assert, instead of correctly handling the situation.
Looking at the relevant code, I believe that there is a calculation issue instead.
Due to floating-point errors, I had to add a floor(..)
, which could cause a non-zero frame to be scaled to zero size.
Can you please provide the image which causes the issue? It would make it easier to test. If that is not posssible, can you please provide the resolution of the image.
Hi, thanks for reporting this issue. Looking at the crash indicates that the context bitmap has size
{0,0}
:*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:' UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}, scale=1.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.'
I believe that simply using the
UIGraphicsImageRenderer
is not a valid solution, because it basically just avoids the assert, instead of correctly handling the situation.Looking at the relevant code, I believe that there is a calculation issue instead. Due to floating-point errors, I had to add a
floor(..)
, which could cause a non-zero frame to be scaled to zero size.Can you please provide the image which causes the issue? It would make it easier to test. If that is not posssible, can you please provide the resolution of the image.
The image is as follow image:
I found the issue and it is unrelated to the resizing of images, but instead there is an edge case that wasn't handled with zero available space left on a page.
Can you please your application with the code on branch issue-366
and let me know if the issue is resolved?
If so, I'll merge the changes into main and release a new version
I found the issue and it is unrelated to the resizing of images, but instead there is an edge case that wasn't handled with zero available space left on a page.
Can you please your application with the code on branch
issue-366
and let me know if the issue is resolved?If so, I'll merge the changes into main and release a new version
ok I will test this fix later and notify you the result
I found the issue and it is unrelated to the resizing of images, but instead there is an edge case that wasn't handled with zero available space left on a page.
Can you please your application with the code on branch
issue-366
and let me know if the issue is resolved? If so, I'll merge the changes into main and release a new version
today I test thist case with your branch issue-366,and problem is not occured again.
Perfect, then I am going to release this now
2.5.0 has fixed it
Awesome! Thanks for the update
What did you do?
I want use image to generate a pdf file, on iOS 17, there is crash occured!
What did you expect to happen?
generate images pdf file as expected, but crashed
What happened instead?
TPPDF Environment
TPPDF version: 2.4.1 Xcode version: 15.3 Swift version: 5.10
Demo Code / Project