binSaed / flutter_cached_pdfview

Enhanced PDF view for Flutter.
https://pub.dev/packages/flutter_cached_pdfview
MIT License
121 stars 70 forks source link

ios 18 crash #109

Open eldarkk opened 1 month ago

eldarkk commented 1 month ago

Describe the bug App crashes when opens pdf file

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Xcode crash report

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View was already initialized: <FLTPDFView: 0x7f8c39776e90; frame = (0 0; 0 0); layer = <CALayer: 0x600002ef9b80>>'
*** First throw call stack:
(
    1   CoreFoundation                      0x00000001180c9369 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x0000000112a3b106 objc_exception_throw + 62
    2   Foundation                          0x00000001164e56a8 _userInfoForFileAndLine + 0
    3   UIKitCore                           0x0000000144c2a0f8 -[UIView _populateInitialTraitCollection:] + 295
    4   UIKitCore                           0x0000000144c2a533 UIViewCommonInitWithFrame + 691
    5   UIKitCore                           0x0000000144c2a246 -[UIView initWithFrame:] + 95
    6   UIKitCore                           0x0000000144c298be -[UIView init] + 44
    7   flutter_pdfview                     0x0000000111e3a94e -[FLTPDFView initWithFrame:arguments:controler:] + 98
    8   flutter_pdfview                     0x0000000111e3a531 -[FLTPDFViewController initWithFrame:viewIdentifier:arguments:binaryMessenger:] + 146
    9   flutter_pdfview                     0x0000000111e3a46f -[FLTPDFViewFactory createWithFrame:viewIdentifier:arguments:] + 91
    10  Flutter                             0x0000000121308bf1 _ZN7flutter30FlutterPlatformViewsController8OnCreateEP17FlutterMethodCallU13block_pointerFvP11objc_objectE + 873
    11  Flutter                             0x0000000121308727 _ZN7flutter30FlutterPlatformViewsController12OnMethodCallEP17FlutterMethodCallU13block_pointerFvP11objc_objectE + 131
    12  Flutter                             0x000000012196d743 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 168
    13  Flutter                             0x000000012133885c ___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt3_fl10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE_block_invoke + 94
    14  libdispatch.dylib                   0x0000000114e75b3d _dispatch_call_block_and_release + 12
    15  libdispatch.dylib                   0x0000000114e76ec6 _dispatch_client_callout + 8
    16  libdispatch.dylib                   0x0000000114e86d1d _dispatch_main_queue_drain + 1357
    17  libdispatch.dylib                   0x0000000114e867c2 _dispatch_main_queue_callback_4CF + 31
    18  CoreFoundation                      0x000000011802845f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    19  CoreFoundation                      0x0000000118022d87 __CFRunLoopRun + 2515
    20  CoreFoundation                      0x0000000118021fb3 CFRunLoopRunSpecific + 536
    21  GraphicsServices                    0x000000012ccef0cb GSEventRunModal + 137
    22  UIKitCore                           0x000000014450ec3b -[UIApplication _run] + 875
    23  UIKitCore                           0x0000000144513b7c UIApplicationMain + 123
    24  UIKitCore                           0x00000001434a2263 block_destroy_helper.22 + 9747
    25  Clockster.debug.dylib               0x000000010de0c4bb $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 123
    26  Clockster.debug.dylib               0x000000010de0c437 $s9Clockster11AppDelegateC5$mainyyFZ + 39
    27  Clockster.debug.dylib               0x000000010de0c528 __debug_main_executable_dylib_entry_point + 24
    28  dyld                                0x000000010b2c4478 start_sim + 10
    29  ???                                 0x0000000202ff42cd 0x0 + 8640217805
)
libc++abi: terminating due to uncaught exception of type NSException
Halipov commented 1 month ago

just add flutter_pdfview: ^1.3.3 in your pubspec.yaml

binSaed commented 1 month ago

@eldarkk Sorry for that currently I don't have time to maintain this package, as @Halipov said you could use another version of flutter_pdfview

flutter_cached_pdfview is just a wrapper for flutter_pdfview to add some features and make it easier to use

any flutter_pdfview version between >1.0.0 and <2.0.0 should work https://github.com/binSaed/flutter_cached_pdfview/blob/944f87274f3e10ea25f9073791bfdad42c6d1407/pubspec.yaml#L22

FritzMatthaeus commented 3 weeks ago

just add flutter_pdfview: ^1.3.3 in your pubspec.yaml

Thank's for the workaround 👍 it fixed the crash.

@binSaed: I just cloned your repo and run the example to find out, if can fix it. But i could not reproduce it: In your example, calling PDF.cachedFromUrl() does not crash on an iPhone 16, iOS 18, Simulator while running my own app with the same implementation does. Any ideas why? Is this just a pubspec issue or what?

FritzMatthaeus commented 3 weeks ago

As I assumed, it's a pubspec.lock issue. Upgrade your dependencies to fix this issue, there is no need to add flutter_pdfview as an additional package. This is the way i fixed the issue:

1) flutter clean - clean your Flutter project 2) flutter pub upgrade - compared to flutter pub get this will upgrade all dependencies to the next minor versions. Alternatively you can delete your pubspec.lock file and run flutter pub get. 3) cd ios - go to ios Folder 4) rm Podfile.lock - delete your Podfile.lock to upgrade the plugins 5) pod install --repo-update - reinstall your plugins

MoElkilany commented 2 weeks ago

Hello, @binSaed. The problem still exists in iOS 18.1, when zoom in and zoom out , even though I updated to the latest versions of both flutter_pdfview and flutter_cached_pdfview.

Screenshot 2024-11-08 at 10 57 25 PM