Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large amount of resources makes the default role resource operations' pages take long time to load #496

Open
shaheenfawzy opened this issue Jan 23, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@shaheenfawzy
Copy link

Describe the bug
I have a panel with 41 resources whenever I enter the edit, view or create page of the role resource it takes 10 seconds to load on my local machine, I kinda of tried to track down the issue in the package by commenting certain components and/or method calls, and I narrowed it down to the following method call to filter in the setPermissionStateForRecordPermissions function used to set the state for checkbox list component

        if (in_array($operation, ['edit', 'view'])) {

            if (blank($record)) {
                return;
            }
            if ($component->isVisible() && count($permissions) > 0) {
                $component->state(
                    collect($permissions)
                        /** @phpstan-ignore-next-line */
                        ->filter(fn ($value, $key) => $record->checkPermissionTo($key)) // <= here is the slow part
                        ->keys()
                        ->toArray()
                );
            }
        }

To Reproduce
Steps to reproduce the behavior:
I don't know how can you reproduce this amount of resources but if you have a large amount this method call increases the response time very much

Expected behavior
The response time should be that long

Screenshots
Image

please complete the following information:

  • OS: Arch linux
  • Filament 3.2
  • Version 3.3
@shaheenfawzy shaheenfawzy added the bug Something isn't working label Jan 23, 2025
@shaheenfawzy
Copy link
Author

I forgot to highlight the load time on debugbar but as you can see it takes 7 seconds, with pages and widgets disabled only resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants