awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
343 stars 89 forks source link

CuratorPicker causes 6 second load times in the Admin #365

Closed richdynamix closed 11 months ago

richdynamix commented 12 months ago

Filament Version

3.1.9

Plugin Version

3.1.6

PHP Version

8.2.13

Problem description

When using the CuratorPicker form field on a resource, we are seeing load times of about 5-8 seconds to load the create and edit page. Without the CuratorPicker field, we are seeing load times of about 300-400ms

Expected behavior

Ideally, we would want these pages feeling snappy to improve the user experience. Load times over 1 seconds would be considered a bad experience.

Steps to reproduce

Create a post model & resource that utilises the CuratorPicker field and seed the database with about 1500 posts.

    CuratorPicker::make('featured_image')
        ->label('Featured Image')
        ->directory('images')
        ->buttonLabel('Upload Image')
        ->columnSpan([
            'sm' => 2,
        ])
        ->required(),

Benchmark the load times with and without the CuratorPicker. A noticeable difference is seen between these scenarios.

For additional context, we use S3 for media storage and cache storage with a custom AWS url (cloudfront domain). Media library works fine, it is only a performance issue when interacting with the model resources.

Reproduction repository

No response

Relevant log output

No response

awcodes commented 12 months ago

If you define the featured image as a relationship it will probably speed things up. Without getting into the details I think that might be what's happening since there's some storage checks.

richdynamix commented 12 months ago

Unfortunately this never had any positive impact. I use a relationship on the CuratorColumn for the list page, which uses the default 10 items per page. With this field the defined, it renders the 10 items in about 1.4s, without the field defined it is about 280ms. 1.4s is an acceptable load time of this page.

However using the same relationship defined on the CuratorPicker I am still getting about 7.5s load time.

Edit: The interesting thing here is the load time is still about 7.5s on the Create resource, which seems very high for an empty form field where nothing has been defined.

awcodes commented 11 months ago

OK. I might have you sorted with v3.2.3.

I do think you are still going to see slow load times with the images loading when the panel opens though.

What I feel is happening is that the 'thumbnail', 'medium' and 'large' sizes used through the plugin go through Glide, so it has to download your image from s3, convert it to the right size, format etc.

Let me know if you are still having issues after updating. I will close this issue for now as resolved. Feel free to reopen if you have continued issues.

richdynamix commented 11 months ago

I can confirm this has resolved the issue. We are now seeing load times from 900ms to 1.5s which is within the acceptable parameters. Thank you for looking into this.