xpenatan / gdx-teavm

Run Libgdx in a webbrowser with teavm
Apache License 2.0
108 stars 16 forks source link

Refrencing ashley components causes black screen (update: actually scala flatten and flatmap break it) #116

Closed plutobox closed 7 months ago

plutobox commented 7 months ago

Hey! I'm running into an issue where the compiled javascript renders a black screen when I reference any of my ashley components.

You can see this live here (black screen) https://plutobox.github.io/scala-example-gdx-teavm/breakout/

Here's the change that introduced the problem https://github.com/plutobox/scala-example-gdx-teavm/pull/2/files

To fix it, you just need to comment out one line, this one https://github.com/plutobox/scala-example-gdx-teavm/pull/3/files

Then it renders just fine (see blue circle on bottom left of screen) https://plutobox.github.io/scala-example-gdx-teavm/breakout-f/

plutobox commented 7 months ago

Some progress.

This works fine

  override def create(): Unit = {
    (0 to 10).map(x => {
      (0 to x).map(y => {
        y
      })
    })
  }

These both cause black screen of death

  override def create(): Unit = {
    (0 to 10).flatMap(x => {
      (0 to x).map(y => {
        y
      })
    })
  }

  override def create(): Unit = {
    (0 to 10).map(x => {
      (0 to x).map(y => {
        y
      })
    }).flatten
  }

It appears that ashley isnt the culprit. This is a scala related problem in flatten.

plutobox commented 7 months ago

Well that's annoying, here's the workaround

https://github.com/plutobox/scala-example-gdx-teavm/pull/4/files https://plutobox.github.io/scala-example-gdx-teavm/breakout-working/

xpenatan commented 7 months ago

I see a blue circle at bottom left using this example https://plutobox.github.io/scala-example-gdx-teavm/breakout/

image

xpenatan commented 7 months ago

Are you using v1.0.0-b9 ?

try forcing teavm to 0.10.0-dev-8 and see if it happens there. If still happening I think you will need to create a issue in teavm repo.

plutobox commented 7 months ago

I see a blue circle at bottom left using this example https://plutobox.github.io/scala-example-gdx-teavm/breakout/

image

That's... strange. No circle for me on firefox/chrome, and cache isn't the problem. Checked on my mobile iOS and same result. Upgrading to 0.10.0-dev-8 didn't fix either.

Yeah closing this out, appears to be a teavm problem... or a me problem. Thanks for your eyes on this