[IOS] LoadDocument two times null exception

Good afternoon,

on IOS loading 2 documents firing the LoadDocument method two times (keeping the instance) makes the app to crash due to a null exception:


System.NullReferenceException: 'Object reference not set to an instance of an object'

  at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.OnPdfViewerPropertyChanged (System.String propertyName) [0x00019] in <e3887dd93bbb4bbeaa7bec6113fd8f2b>:0 
  at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.OnInputFileStreamChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x003fa] in <e3887dd93bbb4bbeaa7bec6113fd8f2b>:0 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311 
  at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.set_InputFileStream (System.IO.Stream value) [0x00000] in <e3887dd93bbb4bbeaa7bec6113fd8f2b>:0 
  at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.LoadDocument (System.IO.Stream stream) [0x0003e] in <e3887dd93bbb4bbeaa7bec6113fd8f2b>:0 
  at Sendra2.Pages.PDFPage.ContentPage_Appearing (System.Object sender, System.EventArgs e) [0x00077] in C:\SORGENTI\Sendra2\Sendra2\Sendra2\Pages\PDFPage.xaml.cs:87 
  at Xamarin.Forms.Page.SendAppearing () [0x0004b] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:414 
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidAppear (System.Boolean animated) [0x00045] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:209 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at Sendra2.iOS.Application.Main (System.String[] args) [0x00001] in C:\SORGENTI\Sendra2\Sendra2\Sendra2.iOS\Main.cs:17 


On Android and UWP works fine.

Please we need this fix as soon as possible because we are in production.

Thanks in advance

7 Replies 1 reply marked as answer

AV Ashokkumar Viswanathan Syncfusion Team June 25, 2020 11:34 AM UTC

Hi Marco, 

Greetings from Syncfusion support, 

We were unable to reproduce the issue, “Application crashes with null reference exception while loading the PDF document for two times” in iOS Platform.  

Please find the sample in the below link, with which we have tried to reproduce the issue 
 
Kindly share the following details to analyze more on this issue and assist you with the better solution   
  1. Simple sample/ modify the above sample to reproduce the issue. 
  2. PDF document.
  3. SfPdfViewer version.
  4. Xamarin.Forms version.
  5. Replication procedure to reproduce the issue. 

Regards, 
Ashok Kumar Viswanathan. 



HS Helmut Schmidt June 30, 2020 01:22 PM UTC

I think the error is in relation to keeping an instance of the SFPdfViewer/ViewModel in memory and displaying it again.
I took the liberty of modifying your example project and extending it with a navigation page and 2 content pages.
The first page just has a button to redirect you to the second page with the pdf. The second page just loads and displays the pdf.
On second navigation from main page to second page, the exception is triggered.

Note: The example works fine on UWP and Android, it just crashes on iOS. It also worked well on iOS when I tested with version 17.4.0.55

Attachment: GettingStarted119774711_pagified_1870b21b.zip


AV Ashokkumar Viswanathan Syncfusion Team July 1, 2020 06:46 AM UTC

Hi Marco, 
 
Thank you for the information, 
 
We were able to reproduce the issue, “Application crashes with null reference exception while loading the PDF document for multiple instance”. Currently, we are validating the issue and we will update the further details on July 3rd , 2020. 
 
Regards, 
Ashok Kumar Viswanathan. 



AV Ashokkumar Viswanathan Syncfusion Team July 3, 2020 02:08 PM UTC

Hi Marco, 
 
We have confirmed that the issue Application crashes with null reference exception while loading the PDF document for multiple instance is a defect and logged a defect report for this issue. The fix for this issue will be included in our weekly NuGet published under nuget.org on July 14th, 2020.  
 
Please find the feedback link below, 
 
Regards, 
Ashok Kumar Viswanathan. 



AV Ashokkumar Viswanathan Syncfusion Team July 14, 2020 01:02 PM UTC

Hi Marco, 
 
We have resolved the issues, ”Application crashes with null reference exception while loading the PDF document for multiple instance” in our weekly NuGet release, so kindly upgrade to latest version v18.2.0.45 to get the issue resolved.  
 
Please find the package link below, 
 
Regards, 
Ashok Kumar Viswanathan. 


Marked as answer

HS Helmut Schmidt July 16, 2020 03:12 PM UTC

I can confirm that the latest NuGet update fixes the crash in the example application.
However, when we tested the update in a more complex, internal project we get the following, new exception when using the back button on navigating away from the page containing the SFPdfViewer:

Object reference not set to an instance of an object
  at Syncfusion.SfPdfViewer.XForms.iOS.ScrollViewEx.ScrollViewEx_Scrolled (System.Object sender, System.EventArgs e) [0x001b1] in <1a99ff7016934ad4a4771c46858f3a90>:0
  at UIKit.UIScrollView+_UIScrollViewDelegate.Scrolled (UIKit.UIScrollView scrollView) [0x0000a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIScrollView.g.cs:1633
--- End of stack trace from previous location where exception was thrown ---

  at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSendSuper_CGPoint(intptr,intptr,CoreGraphics.CGPoint)
  at UIKit.UIScrollView.set_ContentOffset (CoreGraphics.CGPoint value) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIScrollView.g.cs:598
  at Syncfusion.SfPdfViewer.XForms.iOS.ScrollViewEx.set_ContentOffset (CoreGraphics.CGPoint value) [0x00000] in <1a99ff7016934ad4a4771c46858f3a90>:0
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)

Maybe you can deduce something from the stack trace?
Otherwise we'd need to extract the logic in another minimum reproduction sample which will take some time.

Thank you


AV Ashokkumar Viswanathan Syncfusion Team July 17, 2020 03:07 PM UTC

Hi Helmut, 
 
Thank you for contacting Syncfusion support, 
 
We have tried to reproduce the issue, ”Application crashes with null reference exception using back button while navigating” in our end, but its working as expected in our end. 
 
Please find the sample in the below link, 
 
Kindly share the following details to analyze more on this issue and assist you with the better solution      
  1. Simple sample/modify the above sample to replicate the issue.
  2. Xamarin forms version.
  3. Device specification.
  4. Replication video / procedure to reproduce the issue.
 
Regards, 
Ashok Kumar Viswanathan. 


Loader.
Up arrow icon