Xamarin.Forms shell app with PdfViewer crashes out on IOS

I've created a "shell" xamarin forms app in VS 2019, added pdfviewer nuget, added page with pdfviewer tag, when run in IOS simulator or device app crashes when navigating to pdf tab. Works fine in android. Zipped project attached.

Message: Object reference not set to an instance of an object
Source: Syncfusion.SfPdfViewer.XForms
Stack:   at Syncfusion.SfPdfViewer.XForms.SfPdfViewerResources.get_Culture () [0x00006] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Syncfusion.SfPdfViewer.XForms.SfPdfViewerResources.get_sfpdfviewer_bookmarksbutton () [0x00000] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Syncfusion.SfPdfViewer.XForms.TopToolbar..ctor (Syncfusion.SfPdfViewer.XForms.MobileToolbar toolbar) [0x00141] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Syncfusion.SfPdfViewer.XForms.MobileToolbar.Initializelayout () [0x00000] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Syncfusion.SfPdfViewer.XForms.Toolbar.InitializeLayout (Syncfusion.SfPdfViewer.XForms.SfPdfViewer pdfViewer) [0x00065] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Syncfusion.SfPdfViewer.XForms.Toolbar.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00010] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00065] in <bd495b3593264400a9fe06dbebd3b785>:0 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805 
  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1084 
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:320 
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:701 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178 
  at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00144] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:49 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805 
  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1084 
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:320 
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:701 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178 
  at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00144] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:49 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805 
  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1084 
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:320 
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:701 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178 
  at Xamarin.Forms.Page.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0010d] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:285 
  at Xamarin.Forms.Page.UpdateChildrenLayout () [0x000ca] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:361 
  at Xamarin.Forms.Page.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:341 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805 
  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1084 
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:320 
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:701 
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLayoutSubviews () [0x00021] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:179 
  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.1.31/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.1.31/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at XamarinPDFTest.iOS.Application.Main (System.String[] args) [0x00002]

Attachment: XamarinPDFTest_bca2b467.zip

3 Replies

SP Satheesh Palanisamy Syncfusion Team May 25, 2020 06:09 AM UTC

Hi Aaron,    
   
Thank you for contacting Syncfusion support.    
   
We were able to reproduce the issue, “Application crashes while placing the SfPdfViewer in the Xamarin Forms shell”. Currently, we are validating the issue and we will update the further details on May 27 th, 2020.     
  
Regards,    
Satheesh Palanisamy.  



AV Ashokkumar Viswanathan Syncfusion Team May 27, 2020 03:04 PM UTC

Hi Aaron, 

We have analyzed the issue, “Application crashes while placing the SfPdfViewer in the Xamarin Forms shell” in our end. This issue can be resolved in the sample level itself, we need to call ‘Syncfusion.SfPdfViewer.XForms.iOS.SfPdfDocumentViewRenderer.Init();’ in the AppDelegate class of  iOS Project to render the PDFviewer control in iOS platform. 

Please find the modified sample in the below link, 

Please find the UG documentation below, 

Please try the above modified sample, let us know whether provided solution resolved your issue. 

Regards, 
Ashok Kumar Viswanathan. 



AA Aaron May 27, 2020 03:52 PM UTC

That fixed it, many thanks.

Loader.
Up arrow icon