Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal: input characters echoing is broken after running a test suite #147

Closed
dabrain34 opened this issue Nov 6, 2023 · 9 comments · Fixed by #164
Closed

terminal: input characters echoing is broken after running a test suite #147

dabrain34 opened this issue Nov 6, 2023 · 9 comments · Fixed by #164

Comments

@dabrain34
Copy link
Contributor

The linux terminal does not echo the input characters after running a full test suite run such as:

./fluster.py run -ts JCT-VC-HEVC_V1

Need stty sane to be executed to get back a usable terminal

@dabrain34 dabrain34 changed the title break input characters echoing after running a test suite terminal: input characters echoing is broken after running a test suite Nov 6, 2023
@mdimopoulos
Copy link
Contributor

Thanks for reporting, i can reproduce it! We will take a look into it.

@rgonzalezfluendo
Copy link
Contributor

rgonzalezfluendo commented Nov 7, 2023

I can not reproduce with Alacritty, only with GNOME Terminal.

I can not reproduce with Alacritty+ZSH. Only with BASH (Alacritty or GNOME Terminal)

In my case, a Intel laptop, it is related to OpenGL/VAAPI backend for VDPAU and FFmpeg-H.265-VDPAU decoder.

It can be reproduced only with the following command:

./fluster.py run -ts JCT-VC-HEVC_V1 -d FFmpeg-H.265-VDPAU  -tv AMVP_A_MTK_4 CONFWIN_A_Sony_1 TSUNEQBD_A_MAIN10_Technicolor_2  > /dev/null 2> /dev/null

Do you have an Intel GPU and libvdpau-va-gl1 installed?

@dabrain34
Copy link
Contributor Author

My computer owns an Intel GPU indeed

I dont have libvdpau-va-gl1installed in my ubuntu 22.04 setup.

The following command is also reproducing the issue
./fluster.py run -ts JCT-VC-HEVC_V1 -d FFmpeg-H.265-VDPAU -tv AMVP_A_MTK_4 CONFWIN_A_Sony_1 TSUNEQBD_A_MAIN10_Technicolor_2

@mdimopoulos
Copy link
Contributor

@dabrain34 are you using bash or zsh? Trying to narrow down the issue...

@dabrain34
Copy link
Contributor Author

I'm using bash

@rgonzalezfluendo
Copy link
Contributor

rgonzalezfluendo commented Dec 10, 2023

I was able to isolate the problem in this small piece of code. On my laptop the error is not deterministic, it fails less than half of the time.

from multiprocessing import Pool
from unittest.result import TestResult
from time import perf_counter
import subprocess


jobs=3
failfast=False
timeout=30
verbose=True
tests = [1,2,3]

def run_command(command, verbose = False, check = True, timeout = None):
    """Runs a command"""
    sout = subprocess.DEVNULL if not verbose else None
    serr = subprocess.DEVNULL if not verbose else None
    if verbose:
        print(f'\nRunning command "{" ".join(command)}"')
    try:
        subprocess.run(command, stdout=sout, stderr=serr, check=check, timeout=timeout)
    except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as ex:
        raise ex


def _run_worker(test):
    print("running", test)
    cmd = ['ffmpeg']
    out = run_command(cmd, timeout=timeout, verbose=verbose)
    return out


with Pool(jobs) as pool:

    def _callback(test_result) -> None:
        print(
            test_result,
            flush=True,
        )
        if failfast:
            pool.terminate()

    start = perf_counter()
    for test in tests:
        pool.apply_async(_run_worker, (test,), callback=_callback)
    pool.close()
    pool.join()

@algorythmic
Copy link

It looks like you have multiple ffmpeg processes racing each other to save and restore tty settings. I believe the -nostdin option should avoid this.

rgonzalezfluendo added a commit that referenced this issue Feb 16, 2024
Fix issue with Bash Linux terminal does not echo the input characters
after running a full test suite.

Thanks to Kerin Millar for the help in the bash list [1]

The issue could be reproduced with
```
from multiprocessing import Pool
from unittest.result import TestResult
from time import perf_counter
import subprocess

jobs=3
failfast=False
timeout=30
verbose=True
tests = [1,2,3]

def run_command(command, verbose = False, check = True, timeout = None):
    """Runs a command"""
    sout = subprocess.DEVNULL if not verbose else None
    serr = subprocess.DEVNULL if not verbose else None
    if verbose:
        print(f'\nRunning command "{" ".join(command)}"')
    try:
        subprocess.run(command, stdout=sout, stderr=serr, check=check, timeout=timeout)
    except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as ex:
        raise ex

def _run_worker(test):
    print("running", test)
    cmd = ['ffmpeg']
    out = run_command(cmd, timeout=timeout, verbose=verbose)
    return out

with Pool(jobs) as pool:

    def _callback(test_result) -> None:
        print(
            test_result,
            flush=True,
        )
        if failfast:
            pool.terminate()

    start = perf_counter()
    for test in tests:
        pool.apply_async(_run_worker, (test,), callback=_callback)
    pool.close()
    pool.join()
```

Fixes #147

[1] https://lists.gnu.org/archive/html/help-bash/2024-02/msg00084.html
@rgonzalezfluendo
Copy link
Contributor

I asked in help-bash mail list [1]. And the community did the work ❤️

@dabrain34 and @mdimopoulos can you check solution of PR #164 ?

[1] https://lists.gnu.org/archive/html/help-bash/2024-02/msg00084.html

@rgonzalezfluendo
Copy link
Contributor

FYI: this issue was the origin of https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1910

mdimopoulos pushed a commit that referenced this issue Feb 19, 2024
Fix issue with Bash Linux terminal does not echo the input characters
after running a full test suite.

Thanks to Kerin Millar for the help in the bash list [1]

The issue could be reproduced with
```
from multiprocessing import Pool
from unittest.result import TestResult
from time import perf_counter
import subprocess

jobs=3
failfast=False
timeout=30
verbose=True
tests = [1,2,3]

def run_command(command, verbose = False, check = True, timeout = None):
    """Runs a command"""
    sout = subprocess.DEVNULL if not verbose else None
    serr = subprocess.DEVNULL if not verbose else None
    if verbose:
        print(f'\nRunning command "{" ".join(command)}"')
    try:
        subprocess.run(command, stdout=sout, stderr=serr, check=check, timeout=timeout)
    except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as ex:
        raise ex

def _run_worker(test):
    print("running", test)
    cmd = ['ffmpeg']
    out = run_command(cmd, timeout=timeout, verbose=verbose)
    return out

with Pool(jobs) as pool:

    def _callback(test_result) -> None:
        print(
            test_result,
            flush=True,
        )
        if failfast:
            pool.terminate()

    start = perf_counter()
    for test in tests:
        pool.apply_async(_run_worker, (test,), callback=_callback)
    pool.close()
    pool.join()
```

Fixes #147

[1] https://lists.gnu.org/archive/html/help-bash/2024-02/msg00084.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants