tep_image super slow with full url source for image

Ask the community for help and support.
Post Reply
beppe34
Posts: 13
Joined: Thu Apr 01, 2021 7:26 am
Has thanked: 1 time
Been thanked: 1 time

tep_image super slow with full url source for image

Post by beppe34 »

In my setup the conversion of object var $image to string takes about 60 sec!

I have tracked it down to the src attribute of the image.

Example:
In the function file /admin/includes/functions/html_functions.php: function tep_image I have added this at the end of the function

Code: Select all

// DEBUG    
    $start = microtime(true);
    // convert to string
    $str_image = "$image";
    $time_elapsed_secs = microtime(true) - $start;
    print_r("<br>ConversionTime(sec):" . $time_elapsed_secs." , src:" . $src . "<br>");

    return $str_image;
// END DEBUG
//    return = "$image";
Result for image WITHOUT full url in src:
Image Object ( [prefix] => .../web/V2_Phoenix/admin/ [parameters:protected] => Array (
[src] => images/CE-Phoenix-30-30.png
[border] => 0
[alt] => CE Phoenix v1.0.8.1
[width] => 30
[height] => 30
[title] => CE Phoenix v1.0.8.1
)
)
ConversionTime(sec):0.00018000602722168 , src:images/CE-Phoenix-30-30.png
...
Result for image WITH full url in src:
Image Object ( [prefix] => .../web/V2_Phoenix/admin/ [parameters:protected] => Array (
[src] => http://localhost:8000/includes/language ... s/icon.png
[border] => 0
[alt] => Swedish
[class] => img-fluid
[title] => Swedish
)
)
ConversionTime(sec):60.008405923843 , src:http://localhost:8000/includes/language ... s/icon.png

Environment:
OS: Windows 10
IDE: Apache NetBeans IDE 12.1
PHP: 7.3
Running on NetBeans Built in web server.

It is consistent behavior with my setup.

However - no production site should be run with this setup it is annoying!

Change tep_catalog_href_link function with DIR_WS_CATALOG constant where "local" images are used will fix this for me.

Is there any specific reason to have the full url as source for some image:s when the images is on the local filesystem?
Long time oscommerce user in transit to phoenix_cart
Are there more Swedish users out there - get in touch!
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: tep_image super slow with full url source for image

Post by ecartz »

This site: https://www.blindemanwebsites.com/today ... -in-xampp/ suggests that you may need to turn off mod_cgi in the Apache config.

You also might try turning off admin > Configuration > Images > Calculate Image Size.

You also might check if your anti-virus has configuration relative to this.

The only reason that this matters is that the farther you get from your live store's configuration, the less you are testing it. So things that work locally may not work on your live store. For example, loading images from your hard drive certainly won't work for customer using your live store.
vmn
Posts: 40
Joined: Mon Mar 08, 2021 8:59 am
Has thanked: 3 times
Been thanked: 1 time

Re: tep_image super slow with full url source for image

Post by vmn »

I think that Phoenix is not the culprit.

Results from my local (see specs below) 1.0.8.1 Vanilla installation admin where

Calculate image size = true
Default Image = empty

[09-Apr-2021 12:32:52 Europe/Helsinki] ConversionTime(sec):0.00091099739074707 , src:images/CE-Phoenix-30-30.png
[09-Apr-2021 12:32:52 Europe/Helsinki] ConversionTime(sec):0.00026607513427734 , src:images/icon_phoenix.png
[09-Apr-2021 12:32:52 Europe/Helsinki] ConversionTime(sec):0.00024795532226562 , src:images/icon_phoenix.png
[09-Apr-2021 12:32:52 Europe/Helsinki] ConversionTime(sec):0.00024104118347168 , src:https://www.test.phoenix.stock.1.0.8.1. ... /fruit.jpg

BTW. I added the start timer in the beginning of tep_image to measure the total function time.

Are you really using 1.0.8.1?

My admin/includes/html_output.php looks like this:
...
function tep_catalog_href_link($page = '', $parameters = '') {
return Guarantor::ensure_global('Admin')->catalog($page, phoenix_parameterize($parameters));
}
...

My local dev env:

PC (really old, about 10 years)
CPU 2.8GHZ,4 cores,memory 16GB, hard drive: upgraded to SSD

Software
Windows 10
Oracle VirtualBox 6.1.18, Guest OS: OpenSuse 15.2 LEAP
XAMPP for Linux 7.4.13-0 (Apache 2.4.46)
mod_cgi loaded
PHP 7.4.13
Last edited by vmn on Fri Apr 09, 2021 10:28 am, edited 1 time in total.
beppe34
Posts: 13
Joined: Thu Apr 01, 2021 7:26 am
Has thanked: 1 time
Been thanked: 1 time

Re: tep_image super slow with full url source for image

Post by beppe34 »

Thank´s for your answers! :D

I don't se any way of configure NetBeans inbuilt web-server but nevermind.

This slow conversion only happens with NetBeans inbuilt web-server:
- Windows 10, Apache, no problem
- Ubuntu 20.4, Apache, no problem


However: full URL:s when referencing local resources is not neccesary.

Every html client is capabel of getting resources from
/includes/languages/english/images/icon.gif
vs
https://domain.com/includes/languages/e ... s/icon.gif

As long as the system is not using some CDN(content delivery network) and getting resources from elsewhere, "webroot"-relative urls is OK for the systems resources.
Long time oscommerce user in transit to phoenix_cart
Are there more Swedish users out there - get in touch!
Post Reply