We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
quicktime crash (Read 2333 times)
quicktime crash
Nov 24th, 2006, 6:46pm
 
Hi all,

I keep getting persistent problem with sketches which use Quicktime crashing after about 5min of starting the run.

Here's the offending code (a VERY slightly modified example):

import processing.video.*;

Movie myMovie;

void setup()
{
 size(500, 500);
 background(0);
 // Load and play the video in a loop
 myMovie = new Movie(this, "station.mov");
 myMovie.loop();
}

void movieEvent(Movie myMovie) {
 myMovie.read();
}


void draw()
{
 tint(255, 20);
 image(myMovie, 20, 10);
}



Basically I just want to test feasiblity of using Processing for a video installation scenario and right now obviously it is not a very strong candidate :(

Platform:

MacOSX 10.4.8
QT 7.1.3
Processing 121

Error:

java(188,0xa000cfc0) malloc: *** error for object 0x39b390: double free
java(188,0xa000cfc0) malloc: *** set a breakpoint in szone_error to debug
java(188,0xa000cfc0) malloc: *** error for object 0x3ac770: double free
java(188,0xa000cfc0) malloc: *** set a breakpoint in szone_error to debug
java(188,0x1965600) malloc: *** error for object 0x3cd9d0: double free
java(188,0x1965600) malloc: *** set a breakpoint in szone_error to debug
java(188,0xa000cfc0) malloc: *** error for object 0x343bf0: double free
java(188,0xa000cfc0) malloc: *** set a breakpoint in szone_error to debug

Invalid memory access of location 00000000 eip=9170d80c



I already submitted a bug report. So my question to the group is:

IS there are work around for this problem or this is yet another Quicktime4Java pitfall and I should not expect it to run for more then 5 min period?



thnx in advance to everyone!
Re: quicktime crash
Reply #1 - Nov 27th, 2006, 12:04am
 
that's a quicktime problem that's happening outside the p5 code. i wouldn't worry about it unless your installation for some odd reason involves using that example movie, because you'll probably have different results with another movie, or with quicktime installed on another machine.
Re: quicktime crash
Reply #2 - Dec 2nd, 2006, 5:46am
 
This consistently happens to me with many different quicktime movies, using different codecs. It's unpredictable but eventually happens if the movie is left to play for some amount of time.

Several flavors:

Invalid memory access of location ffffffff eip=91712805
Invalid memory access of location 00000000 eip=(something else)
and occasionally a more normal looking memory address.

I also get those double free warnings, though they don't kill the program.

I've been digging around in the Movie code and nothing jumps out. I'd love to try to fix this if I had an idea of what to do. Any ideas, Ben?

Jacob
Re: quicktime crash
Reply #3 - Dec 3rd, 2006, 12:11am
 
Thnx for posting Jacob,

I too was trying out all sorts of codecs on both intel and powerPc macs over the past week. Still crashes within 5min of starting test presentation.

Looked at JMF, seems like a somewhat convoluted way to deal with video and from what I gathered not very actively supported.

I am not particularly up on Java (and really anything that has to do with more then 8bits of register space Smiley but it seems that there is a memory leak somewhere here.

One very ugly workaround that I can think of is to stop the movie and then start it up. This can be done every 5 min or so. I suspect this would clear the buffer that is being over run though I haven't tried it so I am not 100% sure.

I am going to look at running some example code for QT java just to see if that is the culprit or there is something interesting with Processing implementation of video libs. I am really afraid it's the former Sad

                 thanks to both of you guys!
                           

Re: quicktime crash
Reply #4 - Dec 3rd, 2006, 4:21am
 
Started looking at QT library. OUch!! wow!! they could have made it a bit more criptic and with worse docs but Apple would really have to try Smiley

Big thanx to all devel people for putting up with that API and giving the rest of us something to work with!

Looked through the source code for the video lib (as I mentioned before I really don't know much about Java or non 8bit machines). It all seems to make sense. I think whoever coded it forgot to set "available" to FALSE after the movie is done playing (if someone who actually programs in Java could double check I would appreciate it) but I don't think that's related to my problem.

I coded the following to test my theory from the post above about starting and stopping a movie.


import processing.video.*;
Movie myMovie;


boolean grrr;
int double_grrr;


void setup()
{
 size(600, 600);
 myMovie = new Movie(this, "test_none.mov");
 
 grrr=true;
 double_grrr=0;
}


void draw()
{
 if(grrr)
 {
   myMovie.read();
   
   double_grrr++;
   
   if(double_grrr>199)
   //we read in 200 frames and I know my movie is around 300
   {
     grrr=false;
   }
   //print(double_grrr);
   
 }
 else
 {
   grrr=true;
   double_grrr=0;      //reset our timer var
 
  myMovie.stop();    //here to rewind the movie
  myMovie.play();
  myMovie.read();
 
  //print("\n yo!\n");
 }
 image(myMovie, 0, 0);
}



Also a crash!
Here's the err out:

Exception in thread "Thread-2" java.lang.OutOfMemoryError: requested 272640 bytes for jint in /SourceCache/HotSpot15/HotSpot15-64/src/share/vm/prims/jni.cpp. Out of swap space?
java(368,0x18b8e00) malloc: *** vm_allocate(size=274432) failed (error code=3)



This looks like a big bad memory leak. Any suggestions on how to go about debugging something like this?





Re: quicktime crash
Reply #5 - Dec 3rd, 2006, 8:50am
 
I suspected a memory leak, since sith several videos playing simultaneously the ram allocated for the program just steadily goes up and up (according to activity monitor).

I added the following which gets called roughly once a second (that interval was chosen at random) to manually garbage collect:

Runtime r = Runtime.getRuntime();
r.gc();

and memory leak-like behaviour ceased. Ram allocation stays steady over several minutes of playback.
Re: quicktime crash
Reply #6 - Dec 3rd, 2006, 5:29pm
 
thnx jacob,

Made the changes you recommended.
here's the code, totally hacked together but demos the concept:


import processing.video.*;
Movie myMovie;
Runtime r;



boolean grrr;
int double_grrr;


void setup()
{
 size(600, 600);
 myMovie = new Movie(this, "test_none.mov");
 
 grrr=true;
 double_grrr=0;
}


void draw()
{
 if(grrr)
 {
   myMovie.read();
   
   double_grrr++;
   
   if(double_grrr>199)
   //we read in 200 frames and I know my movie is around 300
   {
     grrr=false;
   }
   //print(double_grrr);
   
 }
 else
 {
   r = Runtime.getRuntime();  //work around for a big bad memory leak!
   r.gc();                   //do garbage collection manually
   
   grrr=true;
   double_grrr=0;      //reset our timer var
 
  myMovie.stop();    //here to rewind the movie
  myMovie.play();
  myMovie.read();
 
  //print("\n yo!\n");
 }
 image(myMovie, 0, 0);
}


I don't get any malloc error messgs now but still a crash within about 5min of starting a run.

Consistently get:
Invalid memory access of location ffffffff eip=9170d402

BTW when I run TOP during the run of my sketch, I see java using anywhere from 98.3% to 103.1% of the CPU usage time. This seems very very wrong to me.

Thnx again to everyone!
Re: quicktime crash
Reply #7 - Dec 3rd, 2006, 9:31pm
 
i suspect your quicktime installation/the setup on your machine (unless others are getting this same problem) since this error:

Invalid memory access of location ffffffff eip=9170d402  

is a run-of-the-mill bad pointer happening inside apple's quicktime code. it's only a question of whether we can avoid triggering it, or if there's something that the p5 video library is doing to trigger it (like causing a more aggressive memory leak).

explicitly running Runtime.gc() shouldn't really do anything, since the gc should have plenty of room to run (especially on your dual core machine).

the percentages from top are funny because you have a dual processor or dual core machine. 103% usage generally means that it's using all or most of one core, plus another 3-5% of the other one. the extra 3-5% is doing things like running the garbage collector and perhaps updating the ui.

so unfortunately, i don't have too many answers for you, but that's at least more background on what's going on. keep me posted if you find out more, obviously it's something that i'd like to have fixed.
Re: quicktime crash
Reply #8 - Dec 3rd, 2006, 10:37pm
 
Ben, thanks for the feedback.

I agree that manually invoking garbage collection shouldn't in principle make a difference, but I tried it just to see, since memory allocation was growing steadily (from a couple to tens of megs /second, not pausing into the gigabytes), and sure enough that stopped that behavior.

Since the video library is just a wrapper around the high-level quicktime playback routines, it's surprising that this is happening... Questions of thread safeness come to mind... but the video code looks straightforward enough, and I'm not all that savvy with threads.

I'm around others working with video in processing on a mac and they have encountered this problem.

Jacob
Re: quicktime crash
Reply #9 - Sep 28th, 2007, 8:58am
 
Hi,

I've had the same problem while playing movies.

I found a solution, which has no memory leak at all, that is consuming 50% of one of my CPU's cores (C2D 2.33Ghz) and it is smooth even with 720p h.264 movies.

Add this http://danieloberhoff.de/processing/FasterMovie.pde to in your sketch folder and add this code to your current project.

Quote:
import processing.video.*;

FasterMovie fm;
PImage mImage;

void setup()  
{
 size(800, 600);
 fm = new FasterMovie(this, "test.mp4", false);
   fm.loop();
}


void draw()  
{
    if ( mImage != null ) image( mImage, 0,0, width, height );

}

void movieImageAvailable ( PImage _movieImage )
{
   mImage = _movieImage;
}


Courtesy to Maddanio for this great solution. Smiley

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_core_pde;action=display;num=1175633922


Re: quicktime crash
Reply #10 - Oct 3rd, 2007, 3:40am
 
hmmm...

something with the setup on my machine is funky. I am pretty much getting the same results as before.

here's a list of the possible offenders on my laptop:


Java 1.5.0_07
QT 7.2.0
Processing 0125
2.16GHz Intel Core Duo


jaylfk, is you setup pretty much the same?

         d
Re: quicktime crash
Reply #11 - Oct 12th, 2007, 7:56pm
 
Yes, pretty much the same except for the 2.33ghz C2D

I had this problem too on previous version of P5, Java, OS X.

Try to see with activity monitor how much memory my given example is consuming. In should be around 50MB.

If you don't mind, you can also send me a zip of your sketch folder and let me check it with my system. Wink
Re: quicktime crash
Reply #12 - Oct 15th, 2007, 2:49am
 
Thank you.

Way over 50mb! 220mb of "real" memory and 2gig of virtual (my poor hard drive!) Still crashes after 5min or so.

Here's a link to the project (zipped):
http://xfer.shiftingplanes.org/new_movie_playback.zip

Isn't the JAVA version I listed the latest available from Apple? I get super confused with the whole 1.5 or 5.0 naming scheme change up Smiley

I am still running 10.4.9, will upgrade to 10.5 and report back if it helps the problem.

Re: quicktime crash
Reply #13 - Oct 15th, 2007, 12:01pm
 
I tried your project with some of my movies that reported to work in my others sketches and it worked (>20Min and i stopped it).

I then try your DV stream test movie with my sketches and it crashed around 2~3 min.

It is probably caused by the way Fical Cut is exporting DV stream to Quicktime Movie or maybe the P5 video lib doesn't like interlaced movie files.

Did you include the Markers when exporting, it could be a cause of the crash ?

If you want to make sure it is related to your movie, just open your DV test movie in Quicktime and export it to MPEG4 high quality and try your sketch with it.

Smiley
Page Index Toggle Pages: 1