Skip to content

Conversation

MonsterOfCookie
Copy link

… As currently the process is.

  1. Load index.html
  2. Synchronously load the javascript files
  3. Preload assets, get them cached in the browser (This is currently, where a player would see the libGDX logo and a progress bar).
  4. (optional) Loading assets into memory with a custom loading screen via an AssetManager

In smaller games this is can be acceptable loads times. However as a game grows I have generally found that whilst the code size (The JS files are around 1-3MB) the art (Artists demanding HD level quality) the process of getting a player into the game becomes longer and drawn out and offputting. I have also been involved in projects where a HTML5 gaming platform would require a single loading experience for all binary and asset loading, providing their own loading screen etc.

I have a working example of a game where the JS is split and a boot strap occurs first then the main game JS is loaded separately. Then any assets are then loaded on demand, e.g. the AssetManager wishes to load a texture, this request is intercepted and the browser instructed to download the asset, then the loading into memory can occur.

Before I unleash this all on the world I wanted to see if I could clean up a couple of things in the GWT backend to make what I did simplier and cleaner looking. So this commit is more about setting the stage ready for the next phase of the loading.

When going through the code, I discovered that the canvasId that can be specified in the configuration is never used. Thus never letting you create and specify your own canvas, this commit fixes that.

  1. I moved the preloading code into separate classes and I created an interface to allow other people to create their own preloaders and reuse the existing download code.
  2. I have removed the config.root property as it was no longer needed, the code now only checks for the presence of the canvasId field.
  3. If the canvasId does exist, the default preloader will still create the progress bar and libGDX logo except upon completion it no longers creates the canvas

This is backwards compatible and I have tested it the project created via the project setup tool.

I hope this makes sense to people, if I have done something I shouldn't have please let me know and I will fix it.

barkholt and others added 3 commits August 8, 2016 01:47
… As currently the process is.

1. Load index.html
2. Synchronously load the javascript files
3. Preload assets, get them cached in the browser (This is currently, where a player would see the libGDX logo and a progress bar).
4. (optional) Loading assets into memory with a custom loading screen via an AssetManager

In smaller games this is can be acceptable loads times. However as a game grows I have generally found that whilst the code size (The JS files are around 1-3MB) the art (Artists demanding HD level quality) the process of getting a player into the game becomes longer and drawn out and offputting. I have also been involved in projects where a HTML5 gaming platform would require a single loading experience for all binary and asset loading, providing their own loading screen etc.

I have a working example of a game where the JS is split and a boot strap occurs first then the main game JS is loaded separately. Then any assets are then loaded on demand, e.g. the AssetManager wishes to load a texture, this request is intercepted and the browser instructed to download the asset, then the loading into memory can occur.

Before I unleash this all on the world I wanted to see if I could clean up a couple of things in the GWT backend to make what I did simplier and cleaner looking. So this commit is more about setting the stage ready for the next phase of the loading.

When going through the code, I discovered that the canvasId that can be specified in the configuration is never used. Thus never letting you create and specify your own canvas, this commit fixes that.

1. I moved the preloading code into separate classes and I created an interface to allow other people to create their own preloaders and reuse the existing download code.
2. I have removed the config.root property as it was no longer needed, the code now only checks for the presence of the canvasId field.
3. If the canvasId does exist, the default preloader will still create the progress bar and libGDX logo except upon completion it no longers creates the canvas

This is backwards compatible and I have tested it the project created via the project setup tool.

I hope this makes sense to people, if I have done something I shouldn't have please let me know and I will fix it.
…into barkholt-gwtaudio_webaudio

# Conflicts:
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtApplication.java
@barkholt
Copy link
Contributor

Haven't looked at the code, but I 100% support the idea of refactoring/modernizing the preloading process on GWT. I understand the need for preloading in order to support the synchronous file API, but if we are only loading asynchronously, we should not have to force the users to wait for the preload (and potentially exhaust browser memory in process).

@roseroser
Copy link

I have the same issue, can any one solve this problem?

James added 20 commits December 12, 2016 10:10
# Conflicts:
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtApplication.java
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/com/badlogic/gdx/graphics/Pixmap.java
# Conflicts:
#	gdx/src/com/badlogic/gdx/graphics/g2d/BitmapFont.java
# Conflicts:
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/resources/soundmanager2-jsmin.js
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/resources/soundmanager2-nodebug-jsmin.js
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/resources/soundmanager2.swf
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/resources/soundmanager2_debug.swf
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/resources/soundmanager2_flash9.swf
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/resources/soundmanager2_flash9_debug.swf
#	gdx/src/com/badlogic/gdx/graphics/g2d/BitmapFont.java
# Conflicts:
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtApplication.java
#	gradle/dependencies.gradle
It will now allow for Gradle to be upgraded, as Jetty was deprecated and removed
…tion on resume, so the sound added on resume was being removed, not the original one.
@CodeMason
Copy link

I've been waiting for this for a while -- any idea when this will be merged?

@MonsterOfCookie
Copy link
Author

I feel this might be pretty out of date now as I made more changes etc. I think what might happen is this could become an extension.

James added 2 commits January 30, 2019 12:33
# Conflicts:
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtApplication.java
#	backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtApplicationConfiguration.java
#	extensions/gdx-setup/src/com/badlogic/gdx/setup/DependencyBank.java
#	extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gradle/wrapper/gradle-wrapper.properties
#	extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/html/build.gradle
#	gradle/dependencies.gradle
#	pom.xml
@SimonIT
Copy link
Member

SimonIT commented Jan 30, 2019

I can't run tests:gdx-tests-gwt:superDev with your changes.

At first, I get this error:

libgdx\tests\gdx-tests-gwt\src\com\badlogic\gdx\tests\gwt\client\GwtTestStarter.java:24: error: GwtTestStarter is not abstract and does not override abstract method getApplicationLogger() in Application
public class GwtTestStarter extends GwtApplication {

After I implemented the methods from GwtApplication, I run into this error:

Compiling module com.badlogic.gdx.tests.gwt.GdxTestsGwt
   [ERROR] Errors in 'libgdx\tests\gdx-tests-gwt\build\gwt\gen\com\badlogic\gwtref\client\IReflectionCacheGenerated.java'
      [WARN] Line 21566: Referencing field 'com.badlogic.gdx.graphics.g2d.SpriteBatch.defaultVertexDataType': field 'com.badlogic.gdx.graphics.g2d.SpriteBatch.defaultVertexDataType' is deprecated
      [WARN] Line 21567: Referencing field 'com.badlogic.gdx.graphics.g2d.SpriteBatch.defaultVertexDataType': field 'com.badlogic.gdx.graphics.g2d.SpriteBatch.defaultVertexDataType' is deprecated
      [WARN] Line 23165: Referencing field 'com.badlogic.gdx.math.Matrix4.tmp': field 'com.badlogic.gdx.math.Matrix4.tmp' is deprecated
      [WARN] Line 29404: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActor': method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActor(Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29405: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActorAt': method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActorAt(ILcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29406: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActorBefore': method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActorBefore(Lcom/badlogic/gdx/scenes/scene2d/Actor;Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29407: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActorAfter': method 'com.badlogic.gdx.scenes.scene2d.ui.Container.addActorAfter(Lcom/badlogic/gdx/scenes/scene2d/Actor;Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29746: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.setWidget': method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.setWidget(Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29747: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.getWidget': method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.getWidget()' is deprecated
      [WARN] Line 29748: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActor': method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActor(Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29749: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActorAt': method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActorAt(ILcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29750: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActorBefore': method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActorBefore(Lcom/badlogic/gdx/scenes/scene2d/Actor;Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 29751: Referencing method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActorAfter': method 'com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.addActorAfter(Lcom/badlogic/gdx/scenes/scene2d/Actor;Lcom/badlogic/gdx/scenes/scene2d/Actor;)' is deprecated
      [WARN] Line 31049: Referencing method 'com.badlogic.gdx.utils.JsonValue.size': method 'com.badlogic.gdx.utils.JsonValue.size()' is deprecated
      [ERROR] Line 13766: No source code is available for type javax.annotation.Nonnull; did you forget to inherit a required module?
      [ERROR] Line 13766: No source code is available for type javax.annotation.meta.When; did you forget to inherit a required module?
   Tracing compile failure path for type 'com.badlogic.gwtref.client.IReflectionCacheGenerated'
      [ERROR] Errors in 'libgdx\tests\gdx-tests-gwt\build\gwt\gen\com\badlogic\gwtref\client\IReflectionCacheGenerated.java'
         [ERROR] Line 13766: No source code is available for type javax.annotation.Nonnull; did you forget to inherit a required module?
         [ERROR] Line 13766: No source code is available for type javax.annotation.meta.When; did you forget to inherit a required module?
   [ERROR] Hint: Check that the type name 'com.badlogic.gwtref.client.IReflectionCacheGenerated' is really what you meant
   [ERROR] Hint: Check that your classpath includes all required source roots
   [ERROR] Errors in 'com/badlogic/gwtref/client/ReflectionCache.java'
      [ERROR] Line 24: Rebind result 'com.badlogic.gwtref.client.IReflectionCacheGenerated' could not be found

Please fix this so we can run the tests.

Is it needed to improve the loading process to change from SoundManager2 to your WebAudioAPIManager implementation? If not, maybe splitting the PR increases the chance to get this merged.

Why did you change the log behavior? If it's not necessary for this PR, you should open a new one with this change.

Why did you deleted the jar's for gwt? The jar's are necessary because we build libGDX with a mix of Maven, Gradle and even Ant.

Some formatting tips to increase the merge chance:

  • Keep the PR small as possible
  • don't change the line ending (like you did for example in GwtApplicationConfiguration.java)
  • some of your created files use 4 spaces as indentation. libgdx uses tabs (for example OnDemandAssetLoader.java)
  • I think changing the gwt version is better in the root project's pom. So <version>${gwt.version}</version> don't need to be changed. Is updating gwt necessary? If yes, the gwt-2.8.2 branch might fix the errors I mentioned. If no, I think staying on the current version is the best choice.

@MonsterOfCookie
Copy link
Author

Please fix this so we can run the tests.

It's open source, feel free to do this yourself.

@MrStahlfelge
Copy link
Member

I took your base idea and it is added now to the GWT backend with #5677
@MonsterOfCookie we miss you on the Discord, would be great to see you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants