Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

CachedImage FFImageLoading for Xamarin.Forms

1567911

Posts

  • DanielLDanielL PLInsider ✭✭✭✭
    edited January 2017

    Is there any way to get any exception mesage? Or something could help to know the real problem?

    You should have a log entry if any Exception occurred. That's why I suspect it it not an FFImageLoading problem, rather Xamarin.Forms layout issue. There were some issues related to not visible View on UWP on this forum. eg: https://forums.xamarin.com/discussion/80604/button-image-does-not-appear-in-uwp-app#latest

  • GuiWaltrickeGuiWaltricke BRMember ✭✭

    @DanielL we are trying to use SVG support but when the screen will show this error happen:

    "System.TypeLoadException: Could not resolve type with token 01000130"

    My code:
    <forms:CachedImage HorizontalOptions="CenterAndExpand" VerticalOptions="Center" WidthRequest="70" HeightRequest="70" Source="{Binding IconeUseallSvg.svg, Converter={StaticResource SvgImageSourceConverter}}" > </forms:CachedImage>

    in my code behind i have:
    using System.Xml.Linq;

    Do you know whats can be?

  • GuiWaltrickeGuiWaltricke BRMember ✭✭

    @DanielL the problem was the linker.... but now when the view appear an exception is thrown: "System.Exception: Unable to allocate pixels for the bitmap."

  • RohitKadlagRohitKadlag USMember

    @daniel-luberda :
    Facing the performance issue while loading the images from cache. I have cached the images before using the app in offline mode. And using my application in offline mode.Still images are loading as if they are downloading from internet.My internet is off while using application. I have cahched more than 10000 thousand images.Ideally images from cache should load instantly.Below is my code snippet for cached Image:-
    cachedImage = new CachedImage()
    {
    HorizontalOptions = LayoutOptions.Center,
    VerticalOptions = LayoutOptions.Start,
    CacheDuration=TimeSpan.MaxValue,
    Aspect = Aspect.Fill,
    DownsampleToViewSize = true,
    TransparencyEnabled = false,
    ErrorPlaceholder = "error.png",
    };

  • JensDemeyJensDemey USMember ✭✭

    @RohitKadlag
    I think you should try the Preload(Async) method to load them in memory.

  • RohitKadlagRohitKadlag USMember

    @JensDemey :I think you are talking about the code while downloading the image. I have downloaded the image already in device. and assigning cacheImage.Source=new ImageUri(key) to the cached Image control.Please share the sample if you have

  • JensDemeyJensDemey USMember ✭✭
    edited January 2017

    @RohitKadlag
    I have these delays even though all my images are directly on the device. Even if you download the images they are still only on disk. In order to show them the application still needs to read the image from the disk into the memory. This is probably the delay that you are seeing.
    This is why I use Preload() when my app starts, this way the images get copied from the disk to the memory and they can be shown instantly. Please note that 1000 images probably won't fit into the memory.

  • RohitKadlagRohitKadlag USMember

    @DanialL:System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at FFImageLoading.Work.ImageLoaderTask2[TImageContainer,TImageView].ThrowIfCancellationRequested () [0x00027] in <729f9cd4f13e4e3890af755c5dcd8247>:0 at FFImageLoading.Work.PlatformImageLoaderTask1+<>c__DisplayClass2_0[TImageView].b__0 () [0x00000] in :0
    at FFImageLoading.Helpers.MainThreadDispatcher+<>c__DisplayClass4_0.b__0 () [0x0000a] in :0

  • RohitKadlagRohitKadlag USMember

    @DanialL:System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at FFImageLoading.Work.ImageLoaderTask2[TImageContainer,TImageView].ThrowIfCancellationRequested () [0x00027] in <729f9cd4f13e4e3890af755c5dcd8247>:0 at FFImageLoading.Work.PlatformImageLoaderTask1+<>c__DisplayClass2_0[TImageView].b__0 () [0x00000] in :0
    at FFImageLoading.Helpers.MainThreadDispatcher+<>c__DisplayClass4_0.b__0 () [0x0000a] in :0

  • DanielLDanielL PLInsider ✭✭✭✭
    edited January 2017

    @GuiWaltricke Did you solve it? Here's working demo of SVG files support: https://github.com/luberda-molinet/FFImageLoading/blob/master/samples/ImageLoading.Forms.Sample/Shared/Pages/SvgSamplePage.xaml

    @RohitKadlag I responded you here: https://github.com/luberda-molinet/FFImageLoading/issues/371#issuecomment-274606438 Let's continue there. Also @JensDemey has a good explanation what might happen (thanks for help).

    @RohitKadlag

    System.Threading.Tasks.TaskCanceledException: A task was canceled.

    It's a handled exception. Image loading tasks are cancelled when a new loading task is assigned for the same view, this is expected behaviour. Please make sure, you didn't enable debugger option to break also when handled exception occur.

  • GuiWaltrickeGuiWaltricke BRMember ✭✭

    @DanielL we give up, skiasharp + ffimagem.svg increase our .apk file in almost 22mb and that's horrible...

    did you know this?

  • DanielLDanielL PLInsider ✭✭✭✭
    edited January 2017

    @GuiWaltricke Yes, they want to improve it though. Read more here: https://github.com/mono/SkiaSharp/issues/174

    Also, please note that SVG files are much smaller, if you have a large number of assets, then SkiaSharp library size is compensated with assets size.

  • DanielLDanielL PLInsider ✭✭✭✭

    FFImageLoading 2.2.8 released

    Features

    • Stream handling optimizations, introduced StreamChecksumsAsKeys configuration property.
    • Implemented AsPNGStreamAsync, AsJPGStreamAsync methods for loading images to Stream instead Views
      C# var outputStream = await ImageService.Instance .LoadUrl("http://domain.com/image.jpg") .Transform(new SomeTransformation()) .AsJPGStreamAsync(quality: 80);

    Fixes

    • Fixed occasional null exception
    • Tuned SchedulerMaxParallelTasks default value
    • Download cache - Use ReadAsByteArrayAsync when no ProgressDownload is needed #449
    • Fixed #466
    • SVG: Windows UAP nuspec dependencies fixes
    • #463 Android BlurredTransformation fixes
    • Modified initial image loading task TaskCreationOptions #439
  • mattleibowmattleibow ZAXamarin Team Xamurai

    @GuiWaltricke, as @DanielL said, we are working on it. We have established that it is the PDF's font subsetter causing issues since it depends on icu, which has a data file of 10MB that cannot be linked out. The reason we can get iOS and UWP to be about 5MB is that they weren't including this.

    What we will do is make the mobile platforms exclude the font subsetter since an extra 10 MB per architecture is a huge price to pay for a slightly smaller PDF. Basically a font subsetter just includes the letters that is used and not the whole font, thus the PDF is a bit smaller. However, this can always be done beforehand in the app's resources. If you are including a font as an asset that is 10MB, that is huge, so you might reduce the font's size beforehand, reducing the app's size and thus the PDF's size.

    https://github.com/mono/SkiaSharp/issues/174

  • DanielLDanielL PLInsider ✭✭✭✭

    That is so cool, great work @mattleibow :) ~5MB should be just right for any project, considering that assets size is also reduced when using svgs (no images).

  • MatthewRMatthewR USMember ✭✭

    On version 2.2.8 I'm having issues with Images failing to load on my LGE Nexus 4 (Android 5.1 - API 22). My images start with IsVisible set to false and are later toggled to true. Images seem to load fine on my Nexus 6 (Android 6.0 - API 23). The issue goes away If I revert to version 2.2.7.

  • JulianPasqueJulianPasque USMember ✭✭✭

    Hey @DanialL, i also get an
    Unhandled Exception:
    System.Threading.Tasks.TaskCanceledException: A task was canceled.

    System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0002d] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:179
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-buil
    d/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 at FFImageLoading.Work.ImageLoaderTask2+<b__3_0>d[TImageContainer,TImageView].MoveNext () [0x0009f] in :0
    --- End of stack trace from previous location where exception was thrown ---

  • JulianPasqueJulianPasque USMember ✭✭✭

    Hey @DanialL, i also get an
    Unhandled Exception:
    System.Threading.Tasks.TaskCanceledException: A task was canceled.

    System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0002d] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:179
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-buil
    d/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3985/4e311372/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 at FFImageLoading.Work.ImageLoaderTask2+<b__3_0>d[TImageContainer,TImageView].MoveNext () [0x0009f] in :0
    --- End of stack trace from previous location where exception was thrown ---

  • DanielLDanielL PLInsider ✭✭✭✭

    @MatthewRames Could you create an issue on project github page and share some code?

    @JulianPasque These are handled exceptions and it's normal as image loading tasks are cancelled when a new image loading task for the same native view is added. Those logs are disabled by default, you probably enabled them through custom FFImageLoading configuration. I would advise to disable logging to console in production environment as it can slow down image loading a lot.

  • JohnOsbornJohnOsborn USMember ✭✭

    I am getting uncaught task cancelation exceptions on xamarin forms Android when a listview containing images is scrolled rapidly.>! Fatal 2/28/2017 11:52:42 PM CurrentDomainOnUnhandledException System.Exception: CurrentDomainOnUnhandledException ---> Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException ---> Java.Lang.ReflectiveOperationException: Exception of type 'Java.Lang.ReflectiveOperationException' was thrown. ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00084] in <5b3d08e615944ce9b13d114a34ef4d7f>:0
    at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00015] in <5b3d08e615944ce9b13d114a34ef4d7f>:0
    at Javax.Net.Ssl.HttpsURLConnectionInvoker.Disconnect () [0x0000a] in <2ecd233ed08c448bbe08307eb64dac2f>:0
    at System.Threading.CancellationToken.ActionToActionObjShunt (System.Object obj) [0x00007] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationCallbackInfo.ExecutionContextCallback (System.Object obj) [0x00007] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00031] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationCallbackInfo.ExecuteCallback () [0x0002a] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.CancellationCallbackCoreWork (System.Threading.CancellationCallbackCoreWorkArguments args) [0x0004a] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (System.Boolean throwOnFirstException) [0x000cb] in <8d19106ba49d4d96a369b203deffc3f5>:0
    --- End of inner exception stack trace ---
    at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (System.Boolean throwOnFirstException) [0x0014f] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.NotifyCancellation (System.Boolean throwOnFirstException) [0x00074] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.Cancel (System.Boolean throwOnFirstException) [0x00006] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.Cancel () [0x00000] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.LinkedTokenCancelDelegate (System.Object source) [0x00007] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationCallbackInfo.ExecutionContextCallback (System.Object obj) [0x00007] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationCallbackInfo.ExecuteCallback () [0x0003c] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.CancellationCallbackCoreWork (System.Threading.CancellationCallbackCoreWorkArguments args) [0x0004a] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (System.Boolean throwOnFirstException) [0x000cb] in <8d19106ba49d4d96a369b203deffc3f5>:0
    --- End of inner exception stack trace ---
    at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (System.Boolean throwOnFirstException) [0x0014f] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.NotifyCancellation (System.Boolean throwOnFirstException) [0x00074] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.Cancel (System.Boolean throwOnFirstException) [0x00006] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.Cancel () [0x00000] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.LinkedTokenCancelDelegate (System.Object source) [0x00007] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationCallbackInfo.ExecutionContextCallback (System.Object obj) [0x00007] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationCallbackInfo.ExecuteCallback () [0x0003c] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.CancellationCallbackCoreWork (System.Threading.CancellationCallbackCoreWorkArguments args) [0x0004a] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (System.Boolean throwOnFirstException) [0x000cb] in <8d19106ba49d4d96a369b203deffc3f5>:0
    --- End of inner exception stack trace ---
    at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (System.Boolean throwOnFirstException) [0x0014f] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.NotifyCancellation (System.Boolean throwOnFirstException) [0x00074] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.Cancel (System.Boolean throwOnFirstException) [0x00006] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at System.Threading.CancellationTokenSource.Cancel () [0x00000] in <8d19106ba49d4d96a369b203deffc3f5>:0
    at FFImageLoading.Work.ImageLoaderTask`2[TImageContainer,TImageView].Cancel () [0x00030] in <2d17e89ae1144fbc85484e7be1030866>:0
    at FFImageLoading.ImageService.CancelWorkFor (FFImageLoading.Work.IImageLoaderTask task) [0x00003] in :0
    at FFImageLoading.Views.ManagedImageView.CancelLoading () [0x00013] in :0
    at FFImageLoading.TaskParameterExtensions.Into (FFImageLoading.Work.TaskParameter parameters, FFImageLoading.Views.ImageViewAsync imageView) [0x00000] in :0
    at FFImageLoading.Forms.Droid.CachedImageRenderer.UpdateBitmap (FFImageLoading.Forms.CachedImage previous) [0x0073f] in <799146197bc14c41a24d7f4a581a09dc>:0
    at FFImageLoading.Forms.Droid.CachedImageRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0001f] in <799146197bc14c41a24d7f4a581a09dc>:0
    at (wrapper delegate-invoke) :invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
    at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in :0
    at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in :0
    at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x000fb] in :0
    at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0014b] in :0
    at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean

  • PhamThanhTongPhamThanhTong USMember ✭✭
    edited March 2017

    @JensDemey said:
    @RohitKadlag
    I have these delays even though all my images are directly on the device. Even if you download the images they are still only on disk. In order to show them the application still needs to read the image from the disk into the memory. This is probably the delay that you are seeing.
    This is why I use Preload() when my app starts, this way the images get copied from the disk to the memory and they can be shown instantly. Please note that 1000 images probably won't fit into the memory.

    I have the same issue. I'm using Xamarin Forms. Seem function Preload can only cached a image file per once when it is called? That means: I need to loop and read all file in directory path, is it right?
    Could you explain more detail how to implement it? Thanks

  • JensDemeyJensDemey USMember ✭✭

    @PhamThanhTong
    Yes, you are getting the idea. However I don't read a directory to find the images since:

    • Every platform has them in different folders
    • I don't want to cache every single image (because it would require too much memory)

    Instead I have defined a static list with the names of the images that are used the most in my application.

    public static List<string> CacheImages = new List<string>
    {
    "baboon.png",
    "candy.png",
    "person.png",
    };
    

    Then at the start of my app I do a simple loop over that list and I call PreloadAsync() on every image.

  • PhamThanhTongPhamThanhTong USMember ✭✭

    @JensDemey said:
    @PhamThanhTong
    Yes, you are getting the idea. However I don't read a directory to find the images since:

    • Every platform has them in different folders
    • I don't want to cache every single image (because it would require too much memory)

    Instead I have defined a static list with the names of the images that are used the most in my application.

    public static List<string> CacheImages = new List<string>
    {
    "baboon.png",
    "candy.png",
    "person.png",
    };
    

    Then at the start of my app I do a simple loop over that list and I call PreloadAsync() on every image.

    Thank you for your solution. But my listview can not use a static list, because it is member list, avatar images are not fixed and users can update it.

  • JensDemeyJensDemey USMember ✭✭

    @PhamThanhTong
    In that case I'm not really sure what could be done. Since the images are dynamic it's almost impossible to cache them beforehand. So I think that there will always be a delay. I don't know where your avatars are saved but the only thing I can recommend is keeping the images as small as possible so that they load faster.

  • PhamThanhTongPhamThanhTong USMember ✭✭
    edited March 2017

    @JensDemey : The my member list will call a Api to download images from server and save into local device, then these images will get ImageSource from files on the local device to display on list.

    It seem like as your comment:

    @JensDemey said:
    @RohitKadlag
    I have these delays even though all my images are directly on the device. Even if you download the images they are still only on disk. In order to show them the application still needs to read the image from the disk into the memory. This is probably the delay that you are seeing.

    I tried to use ListView and ViewCell (not renderer, and enabled RecycleElement) it is OK. Because ViewCell in ListView always call Init() to create new ViewCell. But with that solutions is not good when scrolling or fling in my list. Because listview use fastCell solution will faster.
    But when I use FFImageLoading on fastCell, fastCell solutions will recycle cell. It occured delay loading images .
    I also have log issue on FFImageLoading : https://github.com/luberda-molinet/FFImageLoading/issues/519

    *P/s: FastCell solution https://github.com/twintechs/TwinTechsFormsLib

  • JensDemeyJensDemey USMember ✭✭
    edited March 2017

    @PhamThanhTong
    I haven't used FastCell before so I can't help with that.

    But since you said that you are basically displaying the images from files on the local device you should be able to preload them as well.
    I guess that it would be something like ImageService.Instance.LoadFile("downloadedImagePath").PreloadAsync();

  • MichaelEngelmannMichaelEngelmann FRMember ✭✭
    edited March 2017

    Hi @JensDemey do you have any plans to implement "AsJPGStreamAsync" for UWP ?

    By the way very nice NuGet :-)
    Thanks a lot

  • KameshPareek.5577KameshPareek.5577 USUniversity ✭✭

    Hi,
    I am trying to use this plugin with Xamarin Form App. Not sure if I am missing something. After adding ref. to NuGet package when I deploy Droid app getting below error:

    FFImageLoading.Forms.Droid.CachedImageRenderer while decoding custom attribute: (null)

    I am using the latest stable version v2.2.9.

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    @DanielL @charlybit I have the same exact issue (images not showing in ListView), but I haven't tried to isolate it for a repro. I'm guessing this might be an issue with embedded images.

  • KameshPareek.5577KameshPareek.5577 USUniversity ✭✭

    @KameshPareek.5577 said:
    Hi,
    I am trying to use this plugin with Xamarin Form App. Not sure if I am missing something. After adding ref. to NuGet package when I deploy Droid app getting below error:

    FFImageLoading.Forms.Droid.CachedImageRenderer while decoding custom attribute: (null)

    I am using the latest stable version v2.2.9.

    I think the issue was related to reference in memory, after clearing all Build folder and reopening the solution fixed the issue.

  • JensDemeyJensDemey USMember ✭✭

    @MichaelEngelmann said:
    Hi @JensDemey do you have any plans to implement "AsJPGStreamAsync" for UWP ?

    By the way very nice NuGet :-)
    Thanks a lot

    @MichaelEngelmann
    I think you have the wrong person! All credit to @DanielL

  • TKrallTKrall USMember

    I cannot figure out, how to use the constructor of CropTransformation.
    My image's size is 400w x 500h and I want to cut off 50 pixel from the top and 100 pixel from the left, so that the resulting image will be 300w x 450h.
    I do not want to rescale the image, just cut off these parts.

    Can anybody provide a sample invocation for that?

  • PhamThanhTongPhamThanhTong USMember ✭✭

    @TKrall said:
    I cannot figure out, how to use the constructor of CropTransformation.
    My image's size is 400w x 500h and I want to cut off 50 pixel from the top and 100 pixel from the left, so that the resulting image will be 300w x 450h.
    I do not want to rescale the image, just cut off these parts.

    Can anybody provide a sample invocation for that?

    @TKrall :
    You can refer to this guide: How to crop image in Xamarin forms
    Source code: https://github.com/xamarindevelopervietnam/xcropimageforms
    Hope it helps! :smile:

  • UkaszKUkaszK PLMember

    @DanielL
    My application stops responding on xamarin forms Android when a listview containing images is scrolled rapidly.
    I am using version 2.2.9 of FFImage library and list view with ListViewCachingStrategy.RecycleElement.

    I have created my custom image class delivered directly from CachedImage with bindable property named Guid. Changing value of this property updates Source property of my image:

        private void UpdateImage()
        {
            int size = CalculateSize();
            Source = CoverImageHelper.GetUri(Guid, size);
        }
    

    This crash occurs occasionally.

    Any ideas?

  • UkaszKUkaszK PLMember

    I do not know it is solution or workaround, but it works:

    private void UpdateImage()
    {
        int size = CalculateSize();
        Source = null; // set Source property to null before assign new value
        Source = CoverImageHelper.GetUri(Guid, size);
    }
    
  • batmacibatmaci DEMember ✭✭✭✭✭

    @JohnEeckhout said:

    I notice that when I open a page for the first time it's loading the image and adding it to the cache. So for a brief time you can't see the image. The next time that I open the page the image will show instantly. Is there a way to "preload" the images before they are shown on the page so that they will be show instantly the first time as well?

    If anyone was wondering about this as well you can use ImageService.Instance.LoadCompiledResource("myimage.png").Preload();

    do we have to do? ImageService.Instance.Initialize(); in mainactivity on android?

  • LyndonHugheyLyndonHughey USUniversity ✭✭✭
    edited April 2017

    I'm fighting an odd error where the assembly is not recognized during runtime. I'm calling the SvgCachedImage via a XAML page. Resharper is finding the referenced assembly and adding the proper namespaces. However, I keep getting the following error when I run the iOS project on a simulator.

    Xamarin.Forms.Xaml.XamlParseException: Position 7:10. Type ffimageloadingsvg:SvgCachedImage not found in xmlns clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms

    My xaml file is very simple and looks like this:

    <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms" x:Class="FFLoadingSvgTest.MainPage"> <StackLayout> <ffimageloadingsvg:SvgCachedImage WidthRequest="200" HeightRequest="200" Source="sample.svg"/> </StackLayout> </ContentPage>

    I'm using the preview version of the The FFImageLoading.Svg nuget as its the only one that seems to include the SvgCachedImage XAML reference. Oddly, i can run the official FFImageLoading SVG sample, but the image is not displaying, which prompted me to create my own test project.

    I've ensured that I'm calling the "CachedImageRenderer.Init();" method call directly after the forms Init method.

    Is anyone else having a problem using the SVG code? Thanks!

    EDIT: After more investigation, it seems I'm having the same issue that @charlybit had. I've disabled the linker and manually deleted all bin/obj files. I've also removed and reinstalled the nuget packages. This is on an empty project.

  • TimSTimS DEMember ✭✭

    Hi @DanielL,

    I'm having the same issue as @LyndonHughey. After deleting the bin and obj files, the SvgCachedImage could be resolved. But no image is loaded. I can only see white space, where the image should've been rendered.

    I tried the following three variants (x, y and z) to load the image file. The .svg-files were located for y and z as embedded resource within the assembly and for x within the platform's assets/ resource-folder.

    var x = ImageSource.FromFile(imagePath);
    var y = ImageSource.FromResource(imagePath, typeof(App).GetTypeInfo().Assembly);
    var z = ImageSource.FromResource(imagePath);
    var svgImage = new SvgCachedImage()
    {
    Source = z,
    HeightRequest = 100,
    WidthRequest = 100,
    HorizontalOptions = LayoutOptions.Center,
    VerticalOptions = LayoutOptions.Center
    };

  • PierreParmPierreParm FRMember ✭✭

    Hi,

    I'm sorry but I do not really understand how to use the FFImageLoading.
    If I only use the

    Will my image be cached ?
    Or do I need to create a CachedImage in my viewmodel and bind to the Source property of the CachedImage ?

    Thank you !

  • SmeSme USMember ✭✭✭

    I am trying to set the image to have a circle transformation with a border, but the border is not showing up. The image source is done using binding (the images are in a listview), but none the less I am calling cachedImage.SetBinding(CachedImage.Source, "") after I set the transformation.

Sign In or Register to comment.