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

Unsupported video mode: b' \x18\x00\xff\x00\xff\x00\xff\x00\xff\x10\x08\x00' #2

Closed
goodboy opened this issue May 23, 2022 · 14 comments
Closed

Comments

@goodboy
Copy link
Contributor

goodboy commented May 23, 2022

When running the following script against the following server command:
x11vnc -display :0 -noipv6 -forever -noxdamage -ncache_cr

target script:

async def run_client():
    async with asyncvnc.connect(
        'localhost',
        port=5901,
    ) as client:
        print(client)

    asyncio.run(run_client())

output error:

  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/goodboy/repos/piker/snippets/async_vnc.py", line 8, in run_client
    async with asyncvnc.connect(
  File "/usr/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/home/goodboy/repos/asyncvnc/asyncvnc.py", line 563, in connect
    client = await Client.create(reader, writer, username, password, host_key)
  File "/home/goodboy/repos/asyncvnc/asyncvnc.py", line 514, in create
    video=await Video.create(reader, writer))
  File "/home/goodboy/repos/asyncvnc/asyncvnc.py", line 292, in create
    mode = video_modes[await reader.readexactly(13)]
KeyError: b' \x18\x00\xff\x00\xff\x00\xff\x00\xff\x10\x08\x00'

Feels like a full "system test" where you spawn x11vnc and run a client against it would be handy 😄

@goodboy
Copy link
Contributor Author

goodboy commented May 23, 2022

I hacked in a force_video_mode:str = 'rgba' that gets passed on through to Video.create() and that seemed to make everything work. Not sure if that's the solution you want though 😂

@barneygale
Copy link
Owner

Try 45c3117?

@goodboy
Copy link
Contributor Author

goodboy commented May 23, 2022

Ah nice, will do now.

@goodboy
Copy link
Contributor Author

goodboy commented May 23, 2022

Yeah don't think it fixed it.
not really sure i follow that patch but the output is now:

File "/home/goodboy/repos/asyncvnc/asyncvnc.py", line 295, in create
    mode = video_modes[bytes(mode_data)]
KeyError: b'\x10\x10\x00\x01\x00\x1f\x00?\x00\x1f\x0b\x05\x00'

like i said, just forcing Video.mode = 'rgba' makes it work.

@barneygale
Copy link
Owner

That video mode uses 16 bits per pixel, which my code can't/won't support. It's different from your original exception!

@goodboy
Copy link
Contributor Author

goodboy commented May 24, 2022

@barneygale yeah i haven't changed anything. you can see the command line i'm using.

I suggest you run the x11vnc -display :0 -noipv6 -forever -noxdamage -ncache_cr and try to run your code.

If you don't expect that to work it'd be somewhat odd to me,

  • this is a super popular server setup on linux
  • the code works fine if i just force rgba (as mentioned)

So i'm not sure what you'd like to do. I can put up my force mode PR and you can see it work?

goodboy referenced this issue in pikers/asyncvnc May 24, 2022
Since it seems not all video formats are correctly detected yet (eg.
with `x11vnc` basic usage) this allows a user to force a video mode
they know works if wanted.

Pertains to #2.
@goodboy
Copy link
Contributor Author

goodboy commented May 24, 2022

Ahh ok I take it back, the latest error is actually from an x11vnc running in docker setup - so you prolly are right about it being different (i think i connected to the wrong server by accident on that last manual test).

I'm putting up a small test suite shortly that shows your current code works on a local server.
I guess it might be worth it to also show a small container using the settings i have and showing that it works when forcing 'rgba' mode even though you said:

That video mode uses 16 bits per pixel, which my code can't/won't support.

goodboy added a commit to pikers/asyncvnc that referenced this issue May 24, 2022
This is a small starter test suite which verifies basic connection and
auth with a local `x11vnc` server run in a sub-process. Obviously the
`x11vnc` program need to be installed locally for this suite to run.

At the time of writing this test suite exemplifies the following issues:
- barneygale#1
- barneygale#2

Further work to put this into CI is not included here but is highly
recommended ;)
This was referenced May 24, 2022
@barneygale
Copy link
Owner

barneygale commented May 24, 2022

I'm not convinced that the X11 server tells you it's using 16-bit pixels, and then proceeds to send 32-bit pixels; such a thing is an obvious protocol error that would break any VNC client.

16 bits rgb pixels aren't supported because numpy doesn't support any sub-byte packings. Force the VNC server to use true colour if you need to.

@goodboy
Copy link
Contributor Author

goodboy commented May 24, 2022

I'm not convinced that the X11 server tells you it's using 16-bit pixels, and then proceeds to send 32-bit pixels; such a thing is an obvious protocol error that would break any VNC client.

Yeah I have no clue, not my area of knowledge whatsoever 😂
I'm just trying to get your nice client to work for automation.

@barneygale see the test suite in #4 - pretty sure the problem is still there on a plain old server even on 45c3117 history.

@barneygale
Copy link
Owner

barneygale commented May 27, 2022

Could you try latest main?

@goodboy
Copy link
Contributor Author

goodboy commented May 31, 2022

@barneygale for sure, but all you need to do is run that test suite to check 😉

@goodboy
Copy link
Contributor Author

goodboy commented May 31, 2022

@barneygale 💥

tests/test_x11vnc.py::test_basic_connection_maybe_auth[password=None-force_vid=None] PASSED                                                             [ 25%]
tests/test_x11vnc.py::test_basic_connection_maybe_auth[password=None-force_vid=rgba] PASSED                                                             [ 50%]
tests/test_x11vnc.py::test_basic_connection_maybe_auth[password=doggy-force_vid=None] PASSED                                                            [ 75%]
tests/test_x11vnc.py::test_basic_connection_maybe_auth[password=doggy-force_vid=rgba] PASSED                                                            [100%]

====================================================================== 4 passed in 5.28s ======================================================================

Nice work friend!

@goodboy
Copy link
Contributor Author

goodboy commented May 31, 2022

So I think getting that test suite in would be super duper slick 😉

goodboy referenced this issue in pikers/asyncvnc May 31, 2022
Since it seems not all video formats are correctly detected yet (eg.
with `x11vnc` basic usage) this allows a user to force a video mode
they know works if wanted.

Pertains to #2.
goodboy added a commit to pikers/asyncvnc that referenced this issue May 31, 2022
This is a small starter test suite which verifies basic connection and
auth with a local `x11vnc` server run in a sub-process. Obviously the
`x11vnc` program need to be installed locally for this suite to run.

At the time of writing this test suite exemplifies the following issues:
- barneygale#1
- barneygale#2

Further work to put this into CI is not included here but is highly
recommended ;)
goodboy added a commit to pikers/asyncvnc that referenced this issue May 31, 2022
This is a small starter test suite which verifies basic connection and
auth with a local `x11vnc` server run in a sub-process. Obviously the
`x11vnc` program need to be installed locally for this suite to run.

At the time of writing this test suite exemplifies the following issues:
- barneygale#1
- barneygale#2

Further work to put this into CI is not included here but is highly
recommended ;)
goodboy added a commit to pikers/asyncvnc that referenced this issue May 31, 2022
This is a small starter test suite which verifies basic connection and
auth with a local `x11vnc` server run in a sub-process. Obviously the
`x11vnc` program need to be installed locally for this suite to run.

At the time of writing this test suite exemplifies the following issues:
- barneygale#1
- barneygale#2

Further work to put this into CI is not included here but is highly
recommended ;)
@goodboy
Copy link
Contributor Author

goodboy commented Jun 1, 2022

Yup resolved in afbdf1d 🏄🏼

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

No branches or pull requests

2 participants