FFImageLoading icon indicating copy to clipboard operation
FFImageLoading copied to clipboard

FFImageLoading does not work with Xamarin.Forms Previewer

Open omiimo opened this issue 8 years ago • 10 comments

Description

I am struggling to see FFImageLoading output to Xamarin.Froms Previewer. Although I works well when I run on simulator or on a device. It shows exception message on Xamarin.Forms Previewer (Please call CachedImageRenderer.Init method in a platform specific project). I have already configured both android and iOS startup classes correctly as shown in examples.

Steps to Reproduce

  • Create a blank xamarin.forms project
  • install "Xamarin.FFImageLoading.Forms" nuget package
  • Open "AppDelegate" class from iOS project and add "CachedImageRenderer.Init();" method
  • Do the same with Android, open MainActivity.cs and add "CachedImageRenderer.Init(true);" method
  • Now open MainPage.xaml project from shared project and add a FFImageLoading namespace as belos xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"

Try to load image using below xaml tag: <ffimageloading:CachedImage Source="image.png" WidthRequest="200" HeightRequest="200"/>

Expected Behavior

After building project (both iOS and Android) it should show preview in the Xamarin.Forms Previewer.

Actual Behavior

It throws exception in Xamarin.Forms Previewer as "Please call CachedImageRenderer.Init method in a platform specific project"

Basic Information

  • Version with issue: 2.3.6
  • Last known good version:
  • Platform:

Screenshots

Reproduction Link / Code

omiimo avatar Apr 01 '18 20:04 omiimo

I'll need some help with this. Do you have any ideas?

daniel-luberda avatar Apr 04 '18 13:04 daniel-luberda

Seeing the same thing. It seems the FFimageLoading library doesn't think it's been initialized. Other custom renderers are handling this ok, so it should be fixable.

In my current project, I'm also using ImageCirlce (https://github.com/jamesmontemagno/ImageCirclePlugin), so maybe we can look at how it's handling it?

BenReierson avatar Apr 23 '18 05:04 BenReierson

I've confirmed that downgrading to v2.3.5 of just the FFimageLoading.Forms libraries has fixed the Xaml previewer for me. It seems throwing the Init() exception needs some additional consideration for this case. I'm not 100% sure how best to detect if its the xaml previewer that's running, but hopefully that helps.

BenReierson avatar Apr 23 '18 06:04 BenReierson

@BenReierson Could you test 2.4.0-pre-755?

daniel-luberda avatar Apr 24 '18 14:04 daniel-luberda

I can confirm that 2.4.0-pre-755 appears to fix this issue for me. (tested with xamarin.forms 2.5.1)

Thanks. 😀

BenReierson avatar Apr 25 '18 06:04 BenReierson

I'll close this then. Thanks.

daniel-luberda avatar May 02 '18 17:05 daniel-luberda

unfortunately, still not working for in 2.4.0-pre-75 xamarin.forms 2.5.1

here's the screenshot https://www.screencast.com/t/BfGnmD5qFqdn

Nullstr1ng avatar May 04 '18 12:05 Nullstr1ng

Happens in the 3.1.0 version as well

godrose avatar Jun 21 '18 21:06 godrose

@Nullstr1ng @godrose Xamarin.Forms previewer has many issues. It would be great if you could provide any stack trace.

daniel-luberda avatar Jun 22 '18 07:06 daniel-luberda

For me is not working too. FFImageLoading Version: 2.4.3.840 Xamarin Forms Version: 3.2.0.839982

[2018-09-27 19:02:32.4] ERROR: : iOSXamlRenderer had a rendering error: System.Exception: Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading! FFImageLoading.Forms.CachedImage.OnSourcePropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:112 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) in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:417 Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573 Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99 Xamarin.Forms.Xaml.ApplyPropertiesVisitor.TrySetValue (System.Object element, Xamarin.Forms.BindableProperty property, System.Boolean attached, System.Object value, System.Xml.IXmlLineInfo lineInfo, Xamarin.Forms.Xaml.Internals.XamlServiceProvider serviceProvider, System.Exception& exception) in D:\a\1\s\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:487 Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, Xamarin.Forms.Xaml.XmlName propertyName, System.Object value, System.Object rootElement, Xamarin.Forms.Xaml.INode node, Xamarin.Forms.Xaml.HydrationContext context, System.Xml.IXmlLineInfo lineInfo) in D:\a\1\s\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:335 Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ValueNode node, Xamarin.Forms.Xaml.INode parentNode) in D:\a\1\s\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:57 Xamarin.Forms.Xaml.ValueNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:86 Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:143 Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:145 Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:202 Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext) in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:143 Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:89 Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.Type callingType) in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:67 Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.Type callingType) in D:\a\1\s\Xamarin.Forms.Xaml\ViewExtensions.cs:36 com.mycompany.mysolution.myapp.LoginPage.__InitComponentRuntime () com.mycompany.mysolution.myapp.LoginPage.InitializeComponent () in /Users/Lucas/Desktop/Lucas/Projetos/Xamarin/MyApp/src/trunk/MySolution.MyApp/Forms/obj/Debug/Views/LoginPage.xaml.g.cs:29 com.mycompany.mysolution.myapp.LoginPage..ctor () in /Users/Lucas/Desktop/Lucas/Projetos/Xamarin/MyApp/src/trunk/MySolution.MyApp/Forms/Views/LoginPage.xaml.cs:20 System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/MonoMethod.cs:661

lucasbaquino avatar Sep 27 '18 22:09 lucasbaquino