libgdx/gdx-ai

gdx-ai prevents GWT SuperDevMode

MrStahlfelge opened this issue · 14 comments

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.

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.

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

No, unfortunately not.

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

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

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

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

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

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

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.

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.

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.

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.

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