Hit BeforeImageLoad multiple times

Hello,

I am writing MAUI Blazor Hybrid app and use FileManager. I am following this example: https://blazor.syncfusion.com/documentation/file-manager/data-binding#list-objects

Seems when upload image in a folder control hit BeforeImageLoad unlimited times and freeze main app.

When I commend the code:

public async Task BeforeImageLoadAsync(BeforeImageLoadEventArgs<FileManagerDirectoryContent> args)

{

    //var result = await _fileManagerService.GetImage(args.ImageUrl, false, args.FileDetails);

    //result.FileStream.Position = 0;

    //args.FileStream = result.FileStream;

}

Then hit it depend of the images. If I have 2 images will hit the method 2 times. Then the image thumbnails is ok.

But If I delete the method and not hit it at all the image thumbnails is not loaded.


Attachment: Screenshot_2_dd585ec1.jpg

11 Replies

PM Prasanth Madhaiyan Syncfusion Team April 21, 2025 02:28 PM UTC

Hi Dimitar,

Greetings from Syncfusion support.

Based on the shared details, we are currently validating the reported issue by preparing a MAUI Hybrid app with the FileManager component. During our validation, we were able to replicate the mentioned issue at our end. However, we require additional time to investigate this further and will provide you with more details on or before April 23, 2025. We appreciate your patience.

Regards,

Prasanth Madhaiyan.



PM Prasanth Madhaiyan Syncfusion Team April 22, 2025 07:12 AM UTC

Hi Dimitar,

We have checked and considered the reported scenario “Facing an issue where the BeforeImageLoad event is being triggered continuously in the Blazor FileManager” as bug on our end. The fix for this issue will be included in the weekly patch release scheduled for April 29, 2025.


You can track the status of the fix through the following link.


https://www.syncfusion.com/feedback/67117/facing-an-issue-where-the-beforeimageload-event-is-being-triggered-continuously-in


Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Prasanth Madhaiyan.



DI Dimitar replied to Prasanth Madhaiyan April 22, 2025 08:30 AM UTC

Great, thank you. And please add missing thumbnail if method is missing as per my image.



PM Prasanth Madhaiyan Syncfusion Team April 23, 2025 11:01 AM UTC

Hi Dimitar,

Based on the details you shared, it appears that you're encountering broken images in your Blazor FileManager when using the flat data approach with an injected service. This issue occurs because the BeforeImageLoad method is not implemented.

When using flat data with the FileManager component, images are not loaded automatically. The flat data approach requires explicit handling of image loading through the BeforeImageLoad event. To resolve this, you need to implement and use the BeforeImageLoad event handler in your FileManager component.


This event handler is essential because it:

  • Intercepts image load requests
  • Uses your FileManagerService to retrieve the actual image data
  • Provides the image data stream to the FileManager component

Check out the shared details and let us know if you need any further assistance.

Regards,

Prasanth Madhaiyan.



DI Dimitar April 23, 2025 11:12 AM UTC

Hello,

Yes I know how to resolve this when put an empty event. If have 1000 files in the folder FM control need to hit 1000 time this empty event to load default thumbnails. More logically will be when event is missing automatically to load default thumbnails and not to hit 1000 times an empty event. But ok.

Regards,

Dimitar



PM Prasanth Madhaiyan Syncfusion Team April 24, 2025 09:14 AM UTC

Hi Dimitar,

Based on the information you have provided, we understand that you now have a clear understanding of how the BeforeImageLoad event functions when working with the flat data approach in combination with an injected service.

If you have any further questions or need additional clarification, please feel free to reach out. We're always here to help!

Regards,

Prasanth Madhaiyan.



PM Prasanth Madhaiyan Syncfusion Team April 29, 2025 07:47 AM UTC

Hi Dimitar,


Thanks for your patience.


We are glad to announce that our patch release (V29.1.40) has been rolled out successfully.  The issue where “Facing an issue where the BeforeImageLoad event is being triggered continuously in the Blazor FileManager” has been resolved in this release.


To access this fix, we suggest you update the package to 29.1.40 and we include the sample in the latest version for your reference.


Sample : Attached as a zip file.


Feedback : https://www.syncfusion.com/feedback/67117/facing-an-issue-where-the-beforeimageload-event-is-being-triggered-continuously-in


Release notes: https://blazor.syncfusion.com/documentation/release-notes/29.1.40?type=all#file-manager


Root cause : The reported issue occurs due to using the CopyToAsync method from the System.IO library to copy stream data.
Since the underlying stream does not support true asynchronous operations properly, the method does not return any data and the code following CopyToAsync is not executed. As a result, the event continues to trigger repeatedly without throwing any exceptions.


Regards,

Prasanth Madhaiyan.


Attachment: MauiApp1_99ed538a.zip


DJ Daniel Jonsson May 4, 2025 05:23 AM UTC

Hi,

I am experiencing the same issue as Dimitar, and it was not resolved by updating to 29.1.40.

I have a FileManager with some events, one being the BeforeImageLoad event:

            <FileManagerEvents
                TValue="FileManagerDirectoryContent"
                ...
                BeforeImageLoad="BeforeImageLoad"
                />

And then I have implemented my callback method like this:

    async Task BeforeImageLoad(BeforeImageLoadEventArgs<FileManagerDirectoryContent> args)
    {
        args.UseImageAsUrl = false;
        var thumbnailStream = await _fileManagerService.GetThumbnail(args);
        if (thumbnailStream != null)
        {
            args.FileStream = thumbnailStream;
        }
    }

But if I put a breakpoint inside of this method, it gets stuck in a seemingly infinite loop there, and the application freezes.

Is it possible that the bug fix was not included in this release? Or is it possible that the bug can still be triggered in some other way (which I'm unlucky to experience)?



PM Prasanth Madhaiyan Syncfusion Team May 5, 2025 09:33 AM UTC

Hi Daniel Jonsson,

Based on the details you shared, we checked the reported issue using package version 29.1.40, but we were unable to replicate it in the Blazor FileManager component within a MAUI Blazor Hybrid app.

For your reference, we have attached the sample. 

Sample: Attached as a zip file. 

We suspect that the problem may be related to either the browser cache or the NuGet cache, especially after updating to a newer version. To help resolve the issue, we recommend removing the bin and obj folders from your project, then rebuilding and clearing your browser cache.

To assist you in this process, we have attached a blog post that provides step-by-step instructions for clearing the cache.



Please try out the shared details and If the issue still persists, kindly replicate it in the provided sample or share a sample where the issue is being reproduced. This will help us investigate further and provide you with a prompt solution. We look forward to your response with the requested details.

Regards,

Prasanth Madhaiyan.


Attachment: MauiApp1_5ff9d8ea.zip


DI Dimitar May 6, 2025 01:41 PM UTC

I can confirm that the problem do not exist in version 29.1.41




PM Prasanth Madhaiyan Syncfusion Team May 7, 2025 06:40 AM UTC

Hi Dimitar,

Glad to know that your issue has been resolved. Please get back to us for assistance in the future.

Regards,

Prasanth Madhaiyan.


Loader.
Up arrow icon