Building for web (GWT) and futuretask issues

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

Building for web (GWT) and futuretask issues

Postby stosho » Fri Aug 17, 2018 7:56 pm

Currently running into some issues trying to build my project for HTML5 (Android, iOS, and Desktop are all building and running fine).

I'm pretty sure the problem has to do with me using a 3rd party library which happens to use Java methods that are not available/can't be translated to Javascript. Most notably, java.util.concurrent.FutureTask<V> and java.util.concurrent.Callable<V>.

At this point I would hope that there are still some options out there to get this working, I have a few ideas.

1. Inherit some gwt specific module that fixes the problem smoothly and easily. (Probably not possible, but one can hope)
2. Go through the library and manually change everything to not use these unsupported methods. (I'm slightly confused as to why I'm getting errors about the Callable function, when it looks like it is listed here: http://www.gwtproject.org/doc/latest/Re ... concurrent) Changing everything would be a pretty brutal.
3. Somehow create an additional module, similar to the library itself, which implements these 'unsupported methods' using 'supported methods'? Once again I'm not sure if something like this is even possible.

Option 3 seems the most reasonable, but I'm no java/js/gwt expert so maybe something like that wouldn't even be possible.

Any ideas?

Thanks,
stosho
 
Posts: 4
Joined: Mon Dec 04, 2017 6:07 am

Re: Building for web (GWT) and futuretask issues

Postby MrStahlfelge » Sat Aug 18, 2018 9:22 am

Use Gdx specific methods to do what you want:

* postRunnable
* Timer
* Actions.delay
* own counter and handling in act()/render()
* synchronized{}

To give you better recommendations what to use, we would know what you try to achieve.
MrStahlfelge
 
Posts: 91
Joined: Thu Jun 15, 2017 6:40 am

Re: Building for web (GWT) and futuretask issues

Postby stosho » Mon Aug 20, 2018 10:25 pm

Thanks for the reply!

Some more specific details:

- Trying to port a working Android / iOS / Desktop game to HTML5.
- The working project includes third party libraries in the form of .jar's, from what I understand, the full sources are required in order for the HTML5/GWT project to build correctly.

- So, the sources have been included for this 3rd party library, but that does not mean everything is going to work nice just yet. This library makes use of some Java methods that are not available in GWT.
- I am trying to figure out the best way to make this third party library build correctly for GWT.

One option is to go through the 3rd party lib's source code and change everything that uses a method not supported by GWT.

Another option, which seems like it would be doable, and a bit easier all together, would be to create 'another 3rd party lib', which implements these unsupported Java methods using only Java methods that are supported.


A bit more specific:
- I am using the PlayFab Client SDK, which has various calls to the API server using FutureTasks. FutureTasks are not supported in GWT, so I am thinking I could create a custom library (inherited, and built the same way as the PlayFab library), that has a custom implementation of the FutureTask, but only using methods that are supported.

Does this seem doable? Or am I completely off-base with this approach?

Thanks,
stosho
 
Posts: 4
Joined: Mon Dec 04, 2017 6:07 am

Re: Building for web (GWT) and futuretask issues

Postby MrStahlfelge » Sat Sep 01, 2018 3:36 pm

You can do it this way, or by adding GWT-compatible "emulation" classes to your project . LibGDX' does it this way to emulate some Java classes like Locale.
MrStahlfelge
 
Posts: 91
Joined: Thu Jun 15, 2017 6:40 am


Return to General Development

Who is online

Users browsing this forum: No registered users and 1 guest