You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The app crashes when loading a large PDF using this package.
OutOfMemoryError
Failed to allocate a 409743384 byte allocation with 25165824 free bytes and 115MB until OOM, target footprint 441355592, growth limit 536870912
Steps to reproduce
When loading this PDF [https://inductme-uploads.s3.eu-west-2.amazonaws.com/project-media/3f94c61c-577d-451b-9838-d06f9b1a7d62-1731960193425.pdf](Sample PDF)
ExceptionLogsE/AndroidRuntime(17712): at java.util.Arrays.copyOf(Arrays.java:3670)
E/AndroidRuntime(17712): at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:120)
E/AndroidRuntime(17712): at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:95)
E/AndroidRuntime(17712): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:156)
E/AndroidRuntime(17712): at io.flutter.plugin.common.StandardMessageCodec.writeBytes(StandardMessageCodec.java:196)
E/AndroidRuntime(17712): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:247)
E/AndroidRuntime(17712): at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:61)
E/AndroidRuntime(17712): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:272)
E/AndroidRuntime(17712): at com.syncfusion.flutter.pdfviewer.SyncfusionFlutterPdfViewerPlugin.getPage(SyncfusionFlutterPdfViewerPlugin.java:187)
E/AndroidRuntime(17712): at com.syncfusion.flutter.pdfviewer.SyncfusionFlutterPdfViewerPlugin.onMethodCall(SyncfusionFlutterPdfViewerPlugin.java:72)
E/AndroidRuntime(17712): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(17712): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/AndroidRuntime(17712): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime(17712): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(UnknownSource:12)
E/AndroidRuntime(17712): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(17712): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17712): at android.os.Looper.loopOnce(Looper.java:226)
E/AndroidRuntime(17712): at android.os.Looper.loop(Looper.java:313)
E/AndroidRuntime(17712): at android.app.ActivityThread.main(ActivityThread.java:8663)
E/AndroidRuntime(17712): at java.lang.reflect.Method.invoke(NativeMethod)
E/AndroidRuntime(17712): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
On which target platforms have you observed this bug?
Android
Flutter Doctor output
Doctor output
[Add your output here]
The text was updated successfully, but these errors were encountered:
Just to add to this, it seems it's due to the high resolution images which are on the PDF in question - it's less about the size of the actual PDF. We've tried with a different PDF file, same size but not images and it loads fine - the one which does not load has a number of images as detailed here: https://ibb.co/GFJKRSg
This is what chat gpt has to say about it:
The second PDF contains multiple high-resolution images, which significantly increase memory usage when the PDF Viewer plugin attempts to render them. The rendering process converts these images into bitmaps, which consume a large amount of memory.
Bitmaps in Android require uncompressed memory, often at 4 bytes per pixel for ARGB. For example, an image at 3200x3200 resolution could require over 40 MB of memory (3200 × 3200 × 4 bytes).
Flutter's Dart VM Memory Limit: The default memory allocation for Flutter apps may not be sufficient for rendering such resource-heavy PDFs.
Bug description
The app crashes when loading a large PDF using this package.
OutOfMemoryError
Failed to allocate a 409743384 byte allocation with 25165824 free bytes and 115MB until OOM, target footprint 441355592, growth limit 536870912
Steps to reproduce
When loading this PDF [https://inductme-uploads.s3.eu-west-2.amazonaws.com/project-media/3f94c61c-577d-451b-9838-d06f9b1a7d62-1731960193425.pdf](Sample PDF)
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Stack Traces
Stack Traces
On which target platforms have you observed this bug?
Android
Flutter Doctor output
Doctor output
[Add your output here]
The text was updated successfully, but these errors were encountered: