FFImageLoading icon indicating copy to clipboard operation
FFImageLoading copied to clipboard

Performance issues with local images

Open patook opened this issue 10 years ago • 24 comments

Hi - I'm still getting some relatively bad perf issues when loading local images. I think I opened a similar bug a couple months ago but then it was harder to repro.

I recorded a small clip, please look at the images at the bottom of the video. They are all local PNG files and are requested at the exact same time. This uses ff2.1.5

https://www.youtube.com/watch?v=dUVuMpnH2kE&feature=youtu.be

patook avatar Jun 16 '16 20:06 patook

I notice this in my app too.

On Thu, Jun 16, 2016 at 2:32 PM, patook [email protected] wrote:

Hi - I'm still getting some relatively bad perf issues when loading local images. I think I opened a similar bug a couple months ago but then it was harder to repro.

I recorded a small clip, please look at the images at the bottom of the video. They are all local PNG files and are requested at the exact same time. This uses ff2.1.5

https://www.youtube.com/watch?v=dUVuMpnH2kE&feature=youtu.be

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/luberda-molinet/FFImageLoading/issues/252, or mute the thread https://github.com/notifications/unsubscribe/ABvZNEQN9hRb2dSNMFnBMsv8LFjqdfbuks5qMbL3gaJpZM4I3yAd .

ghost avatar Jun 16 '16 21:06 ghost

Did you have some image network requests while having local ones? Also which device was it?

molinch avatar Jun 16 '16 21:06 molinch

@molinch this is an iPhone 6

In the video above, there are only local images being displayed.

However, I have other pages which load remote and local images, and the local images seem to take the longest, even when I set them HighestPriority.

patook avatar Jun 16 '16 22:06 patook

@patook @highplains Could you do this:

  • Create custom logger as here:
        public class CustomLogger : FFImageLoading.Helpers.IMiniLogger
        {
            public void Debug(string message)
            {
                Console.WriteLine(message);
            }

            public void Error(string errorMessage)
            {
                Console.WriteLine(errorMessage);
            }

            public void Error(string errorMessage, Exception ex)
            {
                Error(errorMessage + System.Environment.NewLine + ex.ToString());
            }
        }
  • Use custom FFImageLoading config as here:
            var config = new FFImageLoading.Config.Configuration()
            {
                VerboseLogging = true,
                VerbosePerformanceLogging = true,
                Logger = new CustomLogger(),
            };
            ImageService.Instance.Initialize(config);
  • Run Release build and send us logs which are produced.

daniel-luberda avatar Jun 16 '16 22:06 daniel-luberda

Please post your image loading request. Or you loading via file path or as a compiled/bundled resource?

molinch avatar Jun 17 '16 06:06 molinch

It is pretty simple:

matchesicon.Source = "coffee.png"; discussionsicon.Source = "discussions.png"; etc.

And "coffee.png", "discussions.png", etc. are BundleResources

@daniel-luberda OK I will try to do this today.

patook avatar Jun 17 '16 18:06 patook

https://www.dropbox.com/s/uma74z46pzqkbca/localimages.mov?dl=0

Feels like the network requests are blocking the local image requests. Profile images I have cached already allow the top toolbar to load instant. But if the image has to be downloaded (example in video) seems to block.

ghost avatar Jun 17 '16 21:06 ghost

@highplains Do you priorize local requests? By default they both have same priority and we limit number of concurrent requests.

So if you are limited to a max of 2 concurrent requests, and have 2 running web requests, and request some local stuff, then local request will have to wait until web part is done.

I recommend defining a higher priority on local requests.

molinch avatar Jun 17 '16 21:06 molinch

The local toolbar images are set to "Highest" while everything else on that screen is at "Default"

ghost avatar Jun 17 '16 21:06 ghost

Ok thanks I will check.

molinch avatar Jun 17 '16 21:06 molinch

What's also a little weird is that in the video you can see the first toolbar icon always loads even when a network call is made. But anyways, thanks!

ghost avatar Jun 17 '16 21:06 ghost

echoing what @highplains said, we also have all the local/resources things set to Highest

CachedImage matchesicon = new CachedImage { Source = "coffee.png", LoadingPriority = FFImageLoading.Work.LoadingPriority.Highest }; CachedImage discussionsicon = new CachedImage { Source = "discussions.png", LoadingPriority = FFImageLoading.Work.LoadingPriority.Highest }; CachedImage connicon = new CachedImage { Source = "connections.png", LoadingPriority = FFImageLoading.Work.LoadingPriority.Highest }; CachedImage visitorsicon = new CachedImage { Source = "visitorsicon.png", LoadingPriority = FFImageLoading.Work.LoadingPriority.Highest }; CachedImage usericon = new CachedImage { Source = "usericon.png", LoadingPriority = FFImageLoading.Work.LoadingPriority.Highest };

patook avatar Jun 17 '16 21:06 patook

@patook Is it possible to see performance logs? Thanks

daniel-luberda avatar Jun 17 '16 21:06 daniel-luberda

@daniel-luberda yes, sorry, I'm just in the middle of a big change and need to check in before I can play with this.

patook avatar Jun 17 '16 21:06 patook

Here you go, I had to run it in debug but the same error persists. Is this enough data?

Generating/retrieving image: coffeeselected.png Generating/retrieving image: Discussions.png Generating/retrieving image: connections.png Generating/retrieving image: visitorsicon.png Generating/retrieving image: usericon.png Thread started: #10 Thread started: #11 Thread started: #12 Storing cache key for /Analytics/PostEvent_api [PERFORMANCE] Scheduler - Max: 1, Pending: 4, Running: 1, TotalPending: 5, TotalRunning: 1, TotalMemoryCacheHit: 0, TotalWaiting: 0 Content size for /Analytics/PostEvent_api is 26 [PERFORMANCE] Memory - resident_size: 0MB, resident_size_max: 71MB, virtual_size: 876MB [PERFORMANCE] RunAsync - NetManagedThreadId: 13, NativeThreadId: 16, Execution: 0 ms, ThreadPool: False, Key: coffeeselected.png Thread started: #13 [PERFORMANCE] Scheduler - Max: 1, Pending: 3, Running: 1, TotalPending: 5, TotalRunning: 2, TotalMemoryCacheHit: 0, TotalWaiting: 0 [PERFORMANCE] Memory - resident_size: 0MB, resident_size_max: 72MB, virtual_size: 878MB [PERFORMANCE] RunAsync - NetManagedThreadId: 14, NativeThreadId: 17, Execution: 989 ms, ThreadPool: False, Key: Discussions.png Thread started: #14 [PERFORMANCE] Scheduler - Max: 1, Pending: 2, Running: 1, TotalPending: 5, TotalRunning: 3, TotalMemoryCacheHit: 0, TotalWaiting: 0 [PERFORMANCE] Memory - resident_size: 0MB, resident_size_max: 72MB, virtual_size: 880MB [PERFORMANCE] RunAsync - NetManagedThreadId: 15, NativeThreadId: 18, Execution: 981 ms, ThreadPool: False, Key: connections.png [PERFORMANCE] Scheduler - Max: 1, Pending: 1, Running: 1, TotalPending: 5, TotalRunning: 4, TotalMemoryCacheHit: 0, TotalWaiting: 0 [PERFORMANCE] Memory - resident_size: 0MB, resident_size_max: 72MB, virtual_size: 880MB [PERFORMANCE] RunAsync - NetManagedThreadId: 15, NativeThreadId: 18, Execution: 18 ms, ThreadPool: False, Key: visitorsicon.png [PERFORMANCE] Scheduler - Max: 1, Pending: 0, Running: 1, TotalPending: 5, TotalRunning: 5, TotalMemoryCacheHit: 0, TotalWaiting: 0 [PERFORMANCE] Memory - resident_size: 0MB, resident_size_max: 72MB, virtual_size: 880MB [PERFORMANCE] RunAsync - NetManagedThreadId: 15, NativeThreadId: 18, Execution: 9 ms, ThreadPool: False, Key: usericon.png API call for /Navigation/HeaderNew_api completed. Total wait time = 4702.733ms. Total download time = 0.091ms. Content size = 366

patook avatar Jun 18 '16 00:06 patook

Just so you know, replacing CachedImage with Image (the normal XF image) shows me the image immediately.

patook avatar Jun 18 '16 17:06 patook

@patook Thank you for logs, indeed there's something wrong here:

[PERFORMANCE] RunAsync - NetManagedThreadId: 14, NativeThreadId: 17, Execution: 989 ms, ThreadPool: False, Key: Discussions.png

I'll need to do some tests. Is to possible you could send me those images?

daniel-luberda avatar Jun 21 '16 16:06 daniel-luberda

here they are in order: coffeeselected.png connections.png Discussions.png usericon.png visitorsicon.png

I'm not sure if github re-formats PNG files so if there's no repro, give me an e-mail address and I'll send them to you.

patook avatar Jun 21 '16 16:06 patook

Sure, I'll delete those images here. Email is on my profile page: https://github.com/daniel-luberda

daniel-luberda avatar Jun 21 '16 16:06 daniel-luberda

@daniel-luberda OK e-mailed

patook avatar Jun 21 '16 16:06 patook