I have an application with several Screen and Actor. On my main screen, the actors added to the stage during creation are rendering fine.

However, I have a Netty server running, and when it receive certain events, it adds, in the network thread, new actors to the stage. These are never drawn, despite the main thread continuing to call the render function of the corresponding screen.

In the code below, if I call recieveInbound from the Screen's show by mocking the exact same network payload, the actors are drawn as expected.

What am I doing wrong?


// ...

public MainScreen(Game game) {
    batch = game.getBatch();
    viewport = game.getMainViewport();
    stage = new Stage(viewport, batch);

    try {
        capabilities = GL.getCapabilities();
    catch (IllegalStateException e) {
        capabilities = GL.createCapabilities();

 * Receives and manages signals from the remotes.
 * @param code The received code
 * @param object The received payload
public void receiveInbound(int code, Object object) {

    // Restore OpenGL context if needed before processing.
    try {
    catch (IllegalStateException e) {
    // LOGGER.debug(stage.getActors().size); <-- 1 added in show, as expected
    if (code == 10) {
        LevelMap map = mapManager.serve(code, object);
            .forEach(row -> Arrays.stream(row)
    // LOGGER.debug(stage.getActors().size); <-- 854, as expected

public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    // Expected position, actors are around there.
  • \$\begingroup\$ Join libgdx community on discord. They will help you resolve it much faster. \$\endgroup\$
    – Sneh
    Aug 23, 2021 at 23:36

1 Answer 1


If you are communicating with game using another thread, then bugs can happen. In such cases you can execute code on main thread using this code:

Gdx.app.postRunnable(new Runnable() {
    public void run () {
        // put your code here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .