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

GstBus infinite threads can lead to crash #217

Open
sebastian-meier opened this issue May 12, 2023 · 0 comments
Open

GstBus infinite threads can lead to crash #217

sebastian-meier opened this issue May 12, 2023 · 0 comments

Comments

@sebastian-meier
Copy link

For every new Movie there is a GstBus - Thread being generated. If a Movie is properly disposed after a short playing time and a new Movie is created the old bus is being used (as far as I can tell).

movie.pause();
movie.stop();
movie.dispose();
movie = null;
System.gc();

movie = new Movie...

However if a Movie is playing for longer than a few minutes the thread is not being reused but a new one is created. Over time this can lead to many GstBus Threads which can slow down and even crash the application.

The threads can be checked with VisualVM.

Is there any way to avoid this?

Example (simply change the counter limit to something <= 750):

import processing.video.*;

Movie mov;

void settings() {
  size(800, 600);
}

void setup() {
  mov = new Movie(this, "test1.mp4");
  mov.play();
}

void draw() {
  background(255);

  if (mov != null) {
    try {
      image(mov, 0, 0);
    } catch(ArrayIndexOutOfBoundsException exception) {
       println("not ready");
    }
  }
  counter += 1;
  if (counter > 1000) {
    counter = 0;
    thread("mousePressed");
  }
}

int counter = 0;

void mousePressed() {
  String[] videos = {"test1.mp4", "test2.mp4", "test3.mp4"};
  int vidId = round(random(-0.45, 2.5));
  println(videos[vidId]);
  
  mov.pause();
  mov.stop();
  mov.dispose();
  mov = null;
  System.gc();
  
  mov = new Movie(this, videos[vidId]);
  mov.play();
  
}

void movieEvent(Movie m) {
  if (m.available()) {
     m.read();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant