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

gdx-ai prevents GWT SuperDevMode #95

Open
MrStahlfelge opened this issue Aug 12, 2017 · 14 comments
Open

gdx-ai prevents GWT SuperDevMode #95

MrStahlfelge opened this issue Aug 12, 2017 · 14 comments

Comments

@MrStahlfelge
Copy link
Member

MrStahlfelge commented Aug 12, 2017

Issue details

html:superDev and html:dist works, but when you try to activate superDevMode with the compile button within the web browser, recompiling fails:
[ERROR] Errors in 'com/badlogic/gdx/ai/StandaloneFileSystem.java'
[ERROR] Line 65: Property 'user.home' is not defined.

Debugging is not possible without superdevmode activated.

Version of gdx-ai and/or relevant dependencies

1.8.1, line 65 is concerned.

@alxthm
Copy link

alxthm commented Nov 26, 2017

I have the same issue and can't compile in superDev mode, making debugging impossible 😢 .
It seems the issue comes up when I use the MessageManager class.

Steps to reproduce the issue

Set up a fresh project with the gdx-ai extension. Instantiante a new MessageManager, or use MessageManager.getInstance().
Build the project with html:superDev, and try to compile with the refresh button.

@alxthm
Copy link

alxthm commented Dec 10, 2017

@MrStahlfelge Did you find some way to debug your application without superdevmode?

@MrStahlfelge
Copy link
Member Author

No, unfortunately not.

@davebaol
Copy link
Member

Unfortunately, I won't have the time to investigate in the short run, sorry.
PR welcome :)

@mgsx-dev
Copy link
Contributor

@garbadrom did you call MessageManager class before LibGDX was properly initialized (in your game constructor or in the HTML launcher class) ?

@alxthm
Copy link

alxthm commented Dec 11, 2017

@mgsx-dev No, if I call MessageManager.getInstance() in the renderloop, the bug still comes up.

@mgsx-dev
Copy link
Contributor

@garbadrom and when you're removing this call all is OK ?

@alxthm
Copy link

alxthm commented Dec 11, 2017

Yes. The same issue comes up if I call System.getProperty("user.home") in the render loop, even without using the MessageManager class.

@mgsx-dev
Copy link
Contributor

System.getProperty("user.home") is not expected to work on HTML.

The root cause is that StandaloneFileSystem should not be accessed when you're using libgdx.
It could happen when you're accessing (directly or indirectly) GdxAI class before LibGDX is properly initialized (calling from game constructor or from HTML launcher ...) see here : https://github.com/libgdx/gdx-ai/blob/master/gdx-ai/src/com/badlogic/gdx/ai/GdxAI.java#L48

I can't reproduce this issue with my setup. Maybe more information on your current setup could help : version of gdx-ai, libgdx, gwt ...

@alxthm
Copy link

alxthm commented Dec 11, 2017

Yes, I see ! However I believe the issue comes from the html:superDev compilation, as the issue still comes up even if I call MessageManager.getInstance() in a method that is never called.

I'm using :
gwtVersion='2.8.0'
gdxVersion = '1.9.7'
aiVersion = '1.8.1'
The issue is still here with gdxVersion = 1.9.8.

I've created a repository with a setup that reproduces the issue : https://github.com/garbadrom/GdxAiAndGwtTest.

@ReneHabermann
Copy link

ReneHabermann commented Aug 12, 2018

I had a similar issue with the same exception, but for compiling with dist instead of superdev. It was specifically linked to Behaviourtrees - there, the StandaloneFileSystem was (incorrectly) used. I didn't explicitly call anything ai related before everything was ready. But i found out, that reflection plays a role here. It was quite fragile, but i was able to isolate classes considered for reflection, finally being able to compile and not fail at runtime (due to class not found, because of missing reflection setting). I was only able to solve it by copying the whole btree source into my project, as using the com.badlogic.gdx.btree package for reflection was necessary for runtime, but fails at compilation. Only after splitting it into a different packaging, it worked for me.

So, the gist of it: The thing being active before Libgdx is properly initialized is reflection, at least in my case. This provoked the exception.

@petrov-pro
Copy link

petrov-pro commented May 6, 2019

Yes, i got this error too
[ERROR] Errors in 'com/badlogic/gdx/ai/StandaloneFileSystem.java'
[ERROR] Line 65: Property 'user.home' is not defined.
My env
gwtVersion='2.8.0'
gdxVersion = '1.9.9'
roboVMVersion = '2.3.6'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'

So i cant use gdx-ai for html version ^(
And if you run example @alexandrethm, you get error too.

@payne911
Copy link

Exact same error.

[ERROR] Errors in 'com/badlogic/gdx/ai/StandaloneFileSystem.java'
[ERROR] Line 65: Property 'user.home' is not defined.
    version = '1.0'
    ext {
        appName = "AriseDeeper"
        gdxVersion = '1.9.10'
        roboVMVersion = '2.3.7'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.2'
    }

I only use IndexedAStar for pathfinding.

@tommyettinger
Copy link
Member

I figured out a solution; it may not work for every project but it works here: payne911/Arise_Deeper#1 . I use GWT's super-source mechanism (see core/src/AriseDeeper.gwt.xml, there's a line for super-source) to substitute the GdxFileSystem implementation in place of StandaloneFileSystem (which can't be loaded at all due to the system property access). core/src/emu/ has the super-sourced file. In the GdxDefinition.gwt.xml file, I inherit the game and its super-source after I inherit gdx-ai; I don't know if this matters. I hope this helps someone who finds this issue later...

tommyettinger added a commit that referenced this issue Nov 24, 2021
This allows gdx-ai to be used on GWT without the complex series of workarounds in #95 , because StandaloneFileSystem is swapped out for GdxFileSystem's implementation when running on GWT (which should always have libGDX available).

There are also some key fixes for reflection regarding behavior trees; GWT needs a lot of behavior tree classes made available in the class reflection pool.

Gradle is updated to 6.7.1, the same version libGDX currently uses to build. I want to update this to 7.3, but one step at a time.
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

8 participants