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

2D particle effect freezes when loading a file #6816

Closed
1 of 6 tasks
imohamedibrahim opened this issue Mar 11, 2022 · 7 comments
Closed
1 of 6 tasks

2D particle effect freezes when loading a file #6816

imohamedibrahim opened this issue Mar 11, 2022 · 7 comments
Labels
bug need more info needs more info. Likely to be closed when no reaction given. tools

Comments

@imohamedibrahim
Copy link

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
@imohamedibrahim
Copy link
Author

imohamedibrahim commented Mar 11, 2022

Also one thing,
I tried debugging, I reverted the last commit on extensions/gdx-tools/src/com/badlogic/gdx/tools/particleeditor/ParticleEditor.java in my local and tried running. it works fine.
I think the last commit (https://github.com/libgdx/libgdx/pull/6678/files) caused some problem.

@tommyettinger
Copy link
Member

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.

@crykn
Copy link
Member

crykn commented Mar 14, 2022

I can't reproduce the issue on my end (Windows), neither with the particle editor version on the master branch nor with the one downloadable from the website. This is the particle file I used for testing: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-android/assets/data/test.p

@tommyettinger
Copy link
Member

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...

@crykn
Copy link
Member

crykn commented Mar 15, 2022

Being absolute isn't the only problem with those paths. They still assume that files are located within gdx-tests-lwjgl/data/ and there is a weird mix of / and \. Tbh, I have no idea how they've continued to work at all over the last 11 years... So I guess it would make sense to update those paths.

@crykn crykn added bug need more info needs more info. Likely to be closed when no reaction given. tools labels Mar 15, 2022
@obigu
Copy link
Contributor

obigu commented 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());
							}

@fgnm
Copy link
Contributor

fgnm commented Apr 2, 2022

I have the same problem, the Particle Editor fails to open effects that have only one emitter, like this example:

line-effect
- Delay -
active: false
- Duration - 
lowMin: 3000.0
lowMax: 3000.0
- Count - 
min: 0
max: 200
- Emission - 
lowMin: 0.0
lowMax: 0.0
highMin: 250.0
highMax: 250.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life - 
lowMin: 0.0
lowMax: 0.0
highMin: 500.0
highMax: 1000.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
independent: false
- Life Offset - 
active: false
independent: false
- X Offset - 
active: false
- Y Offset - 
active: false
- Spawn Shape - 
shape: point
- Spawn Width - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- X Scale - 
lowMin: 0.0
lowMax: 0.0
highMin: 32.0
highMax: 32.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Scale - 
active: false
- Velocity - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 30.0
highMax: 30.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 360.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Rotation - 
active: false
- Wind - 
active: false
- Gravity - 
active: false
- Tint - 
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency - 
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options - 
attached: false
continuous: true
aligned: false
additive: true
behind: false
premultipliedAlpha: false
spriteMode: single
- Image Paths -
particle.png

Also, the example point out from @crykn, even if doesn't freeze, it fails to reading of emitters, there should be simple, fire, stars, and smoke, but only the first one is showed:
immagine

As a consequence, preview in Particle Editor is wrong compared to the final result (emitters have wrong position):
immagine

I used the latest build from here: https://libgdx-nightlies.s3.eu-central-1.amazonaws.com/libgdx-runnables/runnable-2D-particles.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug need more info needs more info. Likely to be closed when no reaction given. tools
Projects
None yet
Development

No branches or pull requests

5 participants