question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2D particle effect freezes when loading a file

See original GitHub issue

Please ensure you have given all the following requested information in your report.

Issue details

When I tried importing or loading a 2d particle effect file application freezes with below error

Reproduction steps/code

launch latest particle effect jar, load any particle effect file application will freeze

Version of libGDX and/or relevant dependencies

1.10.0

Stacktrace

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: index can't be >= size: 1 >= 1
        at com.badlogic.gdx.utils.Array.get(Array.java:155)
        at com.badlogic.gdx.tools.particleeditor.ParticleEditor.getEmitter(ParticleEditor.java:208)
        at com.badlogic.gdx.tools.particleeditor.ParticleEditor.reloadRows(ParticleEditor.java:154)
        at com.badlogic.gdx.tools.particleeditor.EffectPanel.emitterSelected(EffectPanel.java:137)
        at com.badlogic.gdx.tools.particleeditor.EffectPanel$10.valueChanged(EffectPanel.java:368)
        at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:224)
        at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:204)
        at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:251)
        at java.desktop/javax.swing.DefaultListSelectionModel.insertIndexInterval(DefaultListSelectionModel.java:675)
        at java.desktop/javax.swing.JTable.tableRowsInserted(JTable.java:4533)
        at java.desktop/javax.swing.JTable.tableChanged(JTable.java:4469)
        at java.desktop/javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:302)
        at java.desktop/javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTableModel.java:237)
        at java.desktop/javax.swing.table.DefaultTableModel.insertRow(DefaultTableModel.java:383)
        at java.desktop/javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:357)
        at java.desktop/javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:368)
        at com.badlogic.gdx.tools.particleeditor.EffectPanel.openEffect(EffectPanel.java:170)
        at com.badlogic.gdx.tools.particleeditor.EffectPanel$5.actionPerformed(EffectPanel.java:315)
        at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
        at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
        at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
        at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
        at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
        at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
        at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
        at java.desktop/java.awt.Component.processEvent(Component.java:6391)
        at java.desktop/java.awt.Container.processEvent(Container.java:2266)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
        at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
        at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
        at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "LWJGL Application" java.lang.IndexOutOfBoundsException: index can't be >= size: 1 >= 1
        at com.badlogic.gdx.utils.Array.get(Array.java:155)
        at com.badlogic.gdx.tools.particleeditor.ParticleEditor.getEmitter(ParticleEditor.java:208)
        at com.badlogic.gdx.tools.particleeditor.ParticleEditor$Renderer.render(ParticleEditor.java:526)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:232)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • macOS

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tommyettingercommented, Mar 11, 2022

I think I have a solution, there’s an off-by-one error, but I’m having tremendous difficulty getting libGDX to build again. There’s some issue I’m having with the new -PjavaVersion system; when I figure it out I’ll try to PR and fix this.

1reaction
obigucommented, Mar 16, 2022

Now I can’t reproduce either… I’ll close my PR. This seems like it could be related to some automatic Git formatting (such as line endings and trailing newlines). @crykn I noticed that the test.p file in the repo uses an absolute path (machine-dependent) for its images; should I make a different PR to change that to a relative path? Not sure what it would be relative to, to be honest…

Yup, we can remove the absolute path and just leave the file name. It works because if it doesn’t find the file it tries to load the image on the same directory the particle effect descriptor file is located. Regarding the path separator it just handles them in code as well.

Relevant code on ParticleEditor.java:

if ((imagePath.contains("/") || imagePath.contains("\\")) && !imageName.contains("..")) {
							file = Gdx.files.absolute(imagePath);
							if (!file.exists()) {
								// try to use image in effect directory
								file = Gdx.files.absolute(new File(effectFile.getParentFile(), imageName).getAbsolutePath());
							}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Very frequent crashes having to do with particle effect
Certain users are crashing very consistently when particle effects are being used. It's difficult to tell which effects it is specifically.
Read more >
2D Particle System - nintervik - GitHub Pages
A tutorial on how to implement a 2D particle system in computer graphics”]
Read more >
Using the Built-in Particle System - Unity - Manual
The Built-in Particle System uses a component, so placing a Particle System in a Scene is a matter of adding a pre-made GameObject...
Read more >
Freezing Particle Systems - Source Filmmaker Tip of the Day ...
In today's Tip of the Day I show you how to freeze a particle system in place, so you can do things like...
Read more >
Particle System User Guide | Unreal Engine 4.27 Documentation
This document will cover the most common workflows of working with Particle Systems and the Particle System editor: Cascade ; To create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found