JVM crash on PImage resize()
in
Core Library Questions
•
1 year ago
Hi All,
I am experiencing a crash in the JVM when dealing with PImages. I believe I have isolated the problem down to the resize() method, inside a class that extends Thread, when using the OPENGL renderer. It's kind of a long series of steps to reproduce, but each the resize, thread, and opengl are needed for the rest of the application. Im using the 2.0a8 release, so I realize bugs are going to be a reality, but it shouldn't be crashing the jvm :)
Here's a little test sketch that illustrates the problem:
- ImgHolder holder;
- void setup () {
- size(300, 300, OPENGL);
- holder = new ImgHolder();
- }
- void draw() {
- translate(10, 10);
- holder.draw();
- }
- void mouseReleased() {
- holder.loadNew("https://www.google.com/images/srpr/logo3w.png");
- }
- class ImgHolder extends Thread{
- String url;
- Boolean running;
- PImage img;
- ArrayList<PImage> imgs = new ArrayList<PImage>();
- int wait = 1000;
- ImgHolder() {
- url ="";
- running = true;
- start();
- }
- void run() {
- while(running){
- try {
- if(url != ""){
- loadTheImage(url);
- }
- sleep((wait));
- } catch (Exception e){ println("Exception"); }
- }
- }
- void draw() {
- if(img != null) {
- image(img, 0, 0);
- }
- }
- void loadNew(String newUrl) {
- url = newUrl;
- }
- void loadTheImage (String url) {
- img = loadImage(url);
- url = "";
- if (img != null) {
- //seems to die here
- if(img.width > img.height){
- img.resize(300, 0);
- } else {
- img.resize(0, 300);
- }
- }
- }
- }
Taking out the OPENGL, the resize() or the Thread seems to solve the problem, but OPENGL is necessary for other parts of the app, I would like to resize the image, and threadding is necessary to load images without halting the application.
Perhaps there is another way of resizing the image? Or maybe this warrents a bug report. Has anyone else experienced this?
thanks!
ak
1