Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[syncfusion_flutter_pdfviewer] OOM issue when reading a large PDF file on Android #2339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tom3652 opened this issue Apr 25, 2025 · 3 comments
Labels
pdf viewer PDF viewer component waiting for customer response Cannot make further progress until the customer responds.

Comments

@Tom3652
Copy link

Tom3652 commented Apr 25, 2025

Bug description

I am receiving some OOM issues from my released app on Android only (this happens much less than before with the latest release) when people are loading large PDFs (80MB+).

The app is crashing because of OOM, while i was hoping for a preloading of 1 page before / after, but not the whole document when a pdf is read.

Steps to reproduce

Try to read a very large PDF (80MB+ is crashing in my app because my app already uses 200MB more or less so the threshold is lowered than in an example app).

Code sample

Code sample
[Add your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Stack Traces

Stack Traces
          Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 82052854 byte allocation with 25165824 free bytes and 95MB until OOM, target footprint 193959104, growth limit 268435456
       at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
       at java.nio.DirectByteBuffer$MemoryRef.<init>(DirectByteBuffer.java:73)
       at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:347)
       at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:62)
       at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:272)
       at com.syncfusion.flutter.pdfviewer.SyncfusionFlutterPdfViewerPlugin.getPage(SyncfusionFlutterPdfViewerPlugin.java:187)
       at com.syncfusion.flutter.pdfviewer.SyncfusionFlutterPdfViewerPlugin.onMethodCall(SyncfusionFlutterPdfViewerPlugin.java:72)
       at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
       at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
       at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0(DartMessenger.java:319)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:9063)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
        

On which target platforms have you observed this bug?

Android

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-x64, locale fr-FR) [1 611ms]
    • Flutter version 3.29.3 on channel stable at /Users/foxtom/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (2 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [4,6s]
    • Android SDK at /Users/foxtom/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [3,1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [31ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [30ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.99.3) [27ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available) [8,7s]
    • Now You See Me (wireless) (mobile) • 00008020-001204401E78002E • ios            • iOS 18.4.1 22E252
    • macOS (desktop)                    • macos                     • darwin-x64     • macOS 15.4.1 24E263 darwin-x64
    • Chrome (web)                       • chrome                    • web-javascript • Google Chrome 135.0.7049.115
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [816ms]
    • All expected network resources are available.

• No issues found!
@Tom3652 Tom3652 changed the title OOM issue when reading a large PDF file on Android only OOM issue when reading a large PDF file on Android only in PDF_Viewer Apr 25, 2025
@Tom3652 Tom3652 changed the title OOM issue when reading a large PDF file on Android only in PDF_Viewer [syncfusion_flutter_pdfviewer] OOM issue when reading a large PDF file on Android Apr 25, 2025
@tungthanh1497
Copy link

I met the same issues with file pdf 21mb only

Image

Device
Brand:Samsung
Model:Galaxy A54 5G
Orientation:Portrait
RAM free: 1.67 GB
Disk free: 8.29 GB

Operating System
Version:Android 14
Orientation:Portrait
Rooted: No

@VijayakumarMariappan VijayakumarMariappan added pdf viewer PDF viewer component open Open labels Apr 28, 2025
@immankumarsync
Copy link
Contributor

Hi,
The OOM (Out of Memory) exception is not related to the overall size of the PDF document but rather to the content and dimension of individual pages. Could you please try enabling the largeHeap option in your AndroidManifest.xml file and check if this resolves the issue?

Image

If the above solution does not work on your end, could you please share the PDF file in which the issue occurs, as this problem appears to be specific to the document? This will help us identify the root cause and provide you with a prompt solution.

If you feel that the documents cannot be shared publicly, you may create a ticket in our support portal to share the requested files securely.

@Deepak1799 Deepak1799 added waiting for customer response Cannot make further progress until the customer responds. and removed open Open labels Apr 30, 2025
@Tom3652
Copy link
Author

Tom3652 commented Apr 30, 2025

Thanks for your answer, i will try to start with the largeHeap parameter to see if it's enough and get back to you after my next app release this week !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pdf viewer PDF viewer component waiting for customer response Cannot make further progress until the customer responds.
Projects
None yet
Development

No branches or pull requests

5 participants