Advanced search  

News:

cpg1.5.42 maintenance release - upgrade recommended
The Coppermine development team is releasing an update for Coppermine in order to fix several minor issues. All fixes are not security critical, so if your gallery is running fine with cpg1.5.36, cpg1.5.38 or cpg1.5.40 you don't need to upgrade. If you are running an older version than cpg1.5.36, you must update to this latest version as soon as possible because of the security impact!
[more]

Pages: [1]   Go Down

Author Topic: CPG lags (sometimes times out with fatal error) when opening page w/ large video  (Read 4943 times)

0 Members and 1 Guest are viewing this topic.

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9

Hello all.

I'm experiencing an issue when using large videos with CPG. When you click on the item in the album, it takes a very long time for the page to load. Sometimes the page doesn't load at all, and ends up in a fatal error (see below). If the page does finally load (~25 seconds later), the video plays fine. It's just getting the page to load initially that seems to be the hang up. Other media on the site loads very quickly, it's just the large videos the cause the page load lag issue. These are very large videos we're talking about (several gigs). These are long 60fps full HD resolution files. Their file sizes can get quite large (5-10gb).

If the page loading times out, these are the two messages I have received...

Fatal error: Maximum execution time of 30 seconds exceeded in /home/********/themes/curve_dark/theme.php on line 292
-and-
Fatal error: Maximum execution time of 30 seconds exceeded in /home/********/include/functions.inc.php on line 5490

For theme.php, the line it gets stuck on (292) is...
Code: [Select]
if ($width == '-1') $width = $CONFIG['picture_table_width']
For functions.inc.php, the line it gets stuck on (5490) is...
Code: [Select]
$size = getimagesize($image);
Now, I'm no developer, and I hardly read PHP, but it looks to me like both of these lines are related to trying to determine image dimensions. Looks to me like CPG is trying to churn through the file to determine its dimensions, but since these file sizes are so large, I'm guessing it's taking the server a large amount of time to churn through the file. I suspect it is likely unable to determine the resolution anyway, since it is not actually an image file (maybe I'm wrong?). If this is the case, it seems it would be helpful for CPG to detect if the file extension is one associated with a video, and if so to bypass the process of trying to determine its dimensions.   ...then again, maybe I'm way off course and it's something completely different. I differ to the experts on this one.

I've setup an example of my issue here: http://www.pictureshome.com/thumbnails.php?album=1
This is a fresh install of CPG, with only two files in an album. One is an image, the other a large video. You will see the significant performance difference between loading the two pages, and occasionally (I suspect based on server load at the time) you will get a fatal error, timing out after 30 seconds.

Thank you all for your time. I appreciate your help.
-= Brandon.
Logged

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9

...anybody?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15035

Code: [Select]
if ($width == '-1') $width = $CONFIG['picture_table_width'];compares just two numbers. That was maybe random that the execution time exceeded exactly there.


Code: [Select]
$size = getimagesize($image);not sure if there are known issues for that PHP function on large files (your example file is 2GiB). I'll check that as soon as possible in my testbed with such large files.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15035

My test results:

File sizePage load time
1 KB~ 0,1 s
10 MB~ 1 s
20 MB~ 3 s
30 MB~ 6 s
40 MB~ 10 s
50 MB~ 15 s

As you can see the file size significantly affects the page load time. I was able to find three resource hogs:
  • cpg_getimagesize in include/functions.inc.php (inside the function theme_html_picture)
  • exif_parse_file in displayimage.php (which itself contains cpg_getimagesize)
  • get_IPTC in displayimage.php (which contains GetImageSize)


Using
Code: [Select]
cpg_getimagesize(true)at all occurrences fixes the issue for me, as it doesn't use PHP's getimagesize function but a custom one. Unfortunately the IPTC data isn't read with that custom function, but maybe there's a different way than getimagesize.


Partly related question: do we really need to use getimagesize and look for EXIF/IPTC data for non-image files? I currently don't know which file formats support EXIF and/or IPTC.
« Last Edit: November 01, 2012, 03:59:20 PM by Αndré »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15035

Should be fixed in SVN revision 8513. Please report any unexpected behavior.
Logged

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9

Thank you so much for working on this issue.

Unfortunately, it seems there's a snag. When you click on an item (either picture or video), it just goes to a blank page. After I enabled Debug Mode, instead of going to a blank page I got the following...

Fatal error: Call to undefined function cpg_picture_dimension_exceeds_intermediate_limit() in /home/********/include/themes.inc.php on line 3275

Thank you again for looking into this issue.
-= Brandon.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15035

Either apply just the changed lines or update all Coppermine files.
Logged

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9

Oh, sorry about that.

I have modified the lines, rather than just copying the changed files over, and pages are loading properly again. Unfortunately, the lag is still happening with the video page.

You can see it with the altered files at: http://www.pictureshome.com/thumbnails.php?album=1

-= Brandon.
Logged

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9

If it helps, here are the modified files I made. Did I make a mistake somewhere in the modifications perhaps?

-= Brandon.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15035

Please review include/themes.inc.php, you moved the line to a wrong location.
Logged
Pages: [1]   Go Up
 

Page created in 0.077 seconds with 20 queries.