Why does my app crash with this exception BUT only when compiled in Release mode, in Debug mode my app works as expected:
The offending code is part of a PDF creation library i'm working on:
The library method signature is:
Initialize (PDFjetPDF As PDF, InputStream1 As InputStream, ImageType As Int)
Initialize the PDFjetImage object.
InputStream1 will be closed when this method completes.
I suspected a corrupt PNG so opened eu-map.png in an image editor and saved it as a new PNG image, still the app crashes in release mode and works in debug mode.
My b4j project also loads a JPG and a BMP image from DirAssets and using the same object and it's Initialize method and these two images work in both debug and release mode:
Why does my InputStream created in debug mode differ from the InputStream created in release mode - is the PNG getting corrupted when compiled?
Any ideas?
Thanks.
Martin.
Program started.
java.lang.Exception: Chunk has bad CRC.
at com.pdfjet.PNGImage.getChunk(PNGImage.java:276)
at com.pdfjet.PNGImage.processPNG(PNGImage.java:234)
at com.pdfjet.PNGImage.<init>(PNGImage.java:65)
at com.pdfjet.Image.<init>(Image.java:129)
at uk.co.martinpearman.b4j.pdfjet.ImageWrapper.Initialize(ImageWrapper.java:43)
at b4j.example.main._createpdfimageexample(main.java:310)
at b4j.example.main._createbutton_action(main.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA$2.run(BA.java:159)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:724)
main._createpdfimageexample (java line: 328)
java.lang.RuntimeException: Object should first be initialized (PDFjetImage).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:28)
at uk.co.martinpearman.b4j.pdfjet.ImageWrapper.SetPosition(ImageWrapper.java:96)
at b4j.example.main._createpdfimageexample(main.java:328)
at b4j.example.main._createbutton_action(main.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA$2.run(BA.java:159)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:724)
The offending code is part of a PDF creation library i'm working on:
B4X:
Dim Image1 As PDFjetImage
Image1.Initialize(PDF1, File.OpenInput(File.DirAssets, "eu-map.png"), PDFjetImageTypes.PNG)
The library method signature is:
Initialize (PDFjetPDF As PDF, InputStream1 As InputStream, ImageType As Int)
Initialize the PDFjetImage object.
InputStream1 will be closed when this method completes.
I suspected a corrupt PNG so opened eu-map.png in an image editor and saved it as a new PNG image, still the app crashes in release mode and works in debug mode.
My b4j project also loads a JPG and a BMP image from DirAssets and using the same object and it's Initialize method and these two images work in both debug and release mode:
B4X:
' Image1 crashes in Release mode, works in Debug mode
' Image2 and Image3 work in both Release and Debug mode
Dim Image1 As PDFjetImage
Image1.Initialize(PDF1, File.OpenInput(File.DirAssets, "eu-map.png"), PDFjetImageTypes.PNG)
Dim Image2 As PDFjetImage
Image2.Initialize(PDF1, File.OpenInput(File.DirAssets, "fruit.jpg"), PDFjetImageTypes.JPG)
Dim Image3 As PDFjetImage
Image3.Initialize(PDF1, File.OpenInput(File.DirAssets, "mt-map.bmp"), PDFjetImageTypes.BMP)
Why does my InputStream created in debug mode differ from the InputStream created in release mode - is the PNG getting corrupted when compiled?
Any ideas?
Thanks.
Martin.