Skip to content

ScreenTerminal always dumps immediatly if forced #1768

@Elec332

Description

@Elec332

Up until 4.0.10, the following code was a valid way to redraw a screen:

while(!stopped) {
    long[] buffer = new long[w * h];
    terminalScreen.dump(1000, true, buffer, null);
    redrawScreen(buffer);
}

With the changes in c2a0b89, this now spikes the system with non-stop redraws.

It also breaks the webterminal on slower systems (output = component.dump(hasInput ? 100 : 10, true);) because the dump now completes instantly for an async transaction (with the pumped streams).

This wasn't a problem before, because the logic of dump(timeout, force, buffer, cursor) was

        if (!dirty && timeout > 0) {
            wait(timeout);
        }
        if (isDirty() || forceDump) {
            dump(fullscreen, cursor);
            return true;
        } else {
            return false;
        }

#1759 included a simplification to

        if (waitDirty(timeout) || forceDump) {
            dump(fullscreen, cursor);
            return true;
        } else {
            return false;
        }

which accomplished the exact same as the old method, without any changes to how the function works.

The AI did not approve and suggested the parameters to be swapped, which would result in an immediate dump if forceDump = true. I commented that this breaks with the old contract of the method, however it would seem that with the mentioned commit it's comment has been taken at face value and was directly applied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions