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

Function used by Save SVG is slowing down wordpress pages #151

Closed
1 task done
Hercilio1 opened this issue Sep 2, 2023 · 0 comments · Fixed by #154
Closed
1 task done

Function used by Save SVG is slowing down wordpress pages #151

Hercilio1 opened this issue Sep 2, 2023 · 0 comments · Fixed by #154
Assignees
Labels
type:bug Something isn't working.
Milestone

Comments

@Hercilio1
Copy link

Hercilio1 commented Sep 2, 2023

Describe the bug

Currently, I use a theme in my WordPress sites that uses the function wp_get_attachment_image for rendering image tags. This function takes the attachment ID and renders its HTML tag (<img>).

I have a huge database with +4,000,000 rows in my wp_posts table. The function wp_attachment_get_image will take 0.1 to 0.2 seconds for rendering SVGs, while the Jpegs and PNGs take only 0.0001 seconds for rending the same tag with the same functions.

Turning on the PHP slow execution log, I could trace back the cause of the slowness. It is the function simplexml_load_file. I added below the file that is using it:
image

So, to summarize, those are the times I have when the Safe SVG is turned on:
image

And those are the times I have with it off:
image

Your plugin is by far the most used by my company. I really would appreciate it if you help me to solve the issue.

Steps to Reproduce

For tracking the timing I used the plugin Query Monitor, together with the following hooks around the function wp_get_attachment_image for tracking the execution time:

do_action( 'qm/start',$this->img_id);
$image = wp_get_attachment_image( $this->img_id, $this->size, false, $this->attr );
do_action( 'qm/stop',$this->img_id);

Another thing you could do in order to reproduce the error would be just to render 30 to 40 SVGs on a page. It would slow the page down, consuming 4 to 10 seconds for rendering the page.

Screenshots, screen recording, code snippet

No response

Environment information

PHP 8.2
WordPress 6.3
Safe SVG 2.2.0

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Hercilio1 Hercilio1 added the type:bug Something isn't working. label Sep 2, 2023
@jeffpaul jeffpaul added this to the 2.2.1 milestone Sep 6, 2023
@jeffpaul jeffpaul moved this from Incoming to To Do in Open Source Practice Sep 6, 2023
@dkotter dkotter changed the title Funciotion used by Save SVG is slowing down wordpress pages Function used by Save SVG is slowing down wordpress pages Sep 12, 2023
@jeffpaul jeffpaul linked a pull request Oct 16, 2023 that will close this issue
4 tasks
@dkotter dkotter modified the milestones: 2.2.1, 2.3.0 Oct 19, 2023
@jeffpaul jeffpaul moved this from To Do to In Review in Open Source Practice Nov 28, 2023
@github-project-automation github-project-automation bot moved this from In Review to Merged in Open Source Practice Dec 12, 2023
@dkotter dkotter modified the milestones: 2.3.0, 2.2.3 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants