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

Virtual output display platform and tests #3056

Merged
merged 52 commits into from
Oct 24, 2023

Conversation

mattkae
Copy link
Contributor

@mattkae mattkae commented Sep 29, 2023

How to test

  • Run miral-shell like so:
bin/miral-app --platform-display-libs=mir:virtual --virtual-output=800x600 --virtual-output=400x300\
  --add-wayland-extensions=zwlr_screencopy_manager_v1:zwlr_virtual_pointer_manager_v1:zwp_virtual_keyboard_manager_v1\
  --startup-apps=wayvnc
  • Run a vnc viewer (I use gvncviewer localhost)
  • View your virtual shell

How to test on a test box

  1. Spin up a box running this branch
  2. Run like so:
sudo XDG_RUNTIME_DIR=/run/ ./bin/miral-shell --virtual-output=800x600 --virtual-output=400x300  --add-wayland-extensions=zwlr_screencopy_manager_v1:zwlr_virtual_pointer_manager_v1:zwp_virtual_keyboard_manager_v1
  1. Install wayvnc
  2. Run wayvnc
sudo XDG_RUNTIME_DIR=/run/ wayvnc <IP_OF_BOX> 5900
  1. On your computer, run gvncviewer IP_OF_BOX

Have fun!

What's new?

  • Implemented the virtual display + input platform
  • The display platform is always supported
  • The input platform is best if the display platform is virtual, otherwise it is dummy
  • Most of the code is stubs and CMakeList.txt
  • Note that I did not have to implement a DisplayBuffer
  • Broke out some X11 option parsing helpers to a shared library so that both the X11 and virt platforms can use them
  • Wrote some tests, but most of the platform is a stub so they are scarce

@mattkae mattkae changed the title (Do not review!) For Matthew's diffing purposes only Virtual output display platform and tests Oct 2, 2023
@mattkae mattkae marked this pull request as ready for review October 2, 2023 22:04
Copy link
Contributor

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, this is hard to evaluate while it doesn't compile, but a few nits mentioned.

As the snaps built I tried Miriway:

$ snap refresh miriway --channel=edge/mir-pr3056
$ miriway --virtual-output 800x600 --virtual-output 1200x900 --platform-display-libs=mir:virt
Info: wayland endpoint 'wayland-0' already exists, using it as host
[2023-10-03 11:16:54.937811] <information> mirserver: Starting
[2023-10-03 11:16:54.953884] < - debug - > mirserver: Not using logind for session management: Logind TakeControl call failed: GDBus.Error:System.Error.EBUSY: Device or resource busy
[2023-10-03 11:16:54.954084] < - debug - > mirserver: Not using Linux VT subsystem for session management: Failed to find the current VT
[2023-10-03 11:16:54.954123] < - debug - > mirserver: No session management supported
[2023-10-03 11:16:54.954171] <information> VT switch key handler: No VT switching support available: MinimalConsoleServices does not support VT switching
[2023-10-03 11:16:54.954500] <information> mircommon: Loading modules from: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform
[2023-10-03 11:16:54.954646] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-eglstream-kms.so.20
[2023-10-03 11:16:54.954705] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.20
[2023-10-03 11:16:54.954732] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-wayland.so.20
[2023-10-03 11:16:54.954755] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/renderer-egl-generic.so.20
[2023-10-03 11:16:54.954778] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-virtual.so.20
[2023-10-03 11:16:54.954814] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-x11.so.20
[2023-10-03 11:16:54.954852] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-evdev.so.8
[2023-10-03 11:16:54.954869] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-dummy.so
[2023-10-03 11:16:54.954921] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-stub.so
[2023-10-03 11:16:54.956931] <information> mirserver: Found display driver: mir:virt (version 2.15.0)
[2023-10-03 11:16:54.956974] <information> mirserver: Driver supports:
[2023-10-03 11:16:54.956988] <information> mirserver:   System (priority 192)
[2023-10-03 11:16:54.957006] <information> mirserver: Selected display driver: mir:virt (version 2.15.0) for platform
[2023-10-03 11:16:54.957248] <information> mircommon: Loading modules from: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform
[2023-10-03 11:16:54.957405] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-eglstream-kms.so.20
[2023-10-03 11:16:54.957436] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.20
[2023-10-03 11:16:54.957459] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-wayland.so.20
[2023-10-03 11:16:54.957483] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/renderer-egl-generic.so.20
[2023-10-03 11:16:54.957552] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-virtual.so.20
[2023-10-03 11:16:54.957605] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-x11.so.20
[2023-10-03 11:16:54.957623] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-evdev.so.8
[2023-10-03 11:16:54.957644] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-dummy.so
[2023-10-03 11:16:54.957679] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-stub.so
[2023-10-03 11:16:54.959316] <information> mirserver: Found rendering driver: mir:eglstream-kms (version 2.15.0)
[2023-10-03 11:16:54.959344] < - debug - > eglstream: No outputs capable of accepting EGLStream input detected
[2023-10-03 11:16:54.959360] < - debug - > eglstream: Probing will be skipped
[2023-10-03 11:16:54.959407] <information> mirserver: (Unsupported by system environment)
[2023-10-03 11:16:54.959428] <information> mirserver: Found rendering driver: mir:gbm-kms (version 2.15.0)
[2023-10-03 11:16:54.959450] < - debug - > gbm-kms: No outputs capable of accepting GBM input detected
[2023-10-03 11:16:54.959481] < - debug - > gbm-kms: Probing will be skipped
[2023-10-03 11:16:54.959492] <information> mirserver: (Unsupported by system environment)
[2023-10-03 11:16:54.959508] <information> mirserver: Found rendering driver: mir:wayland (version 2.15.0)
[2023-10-03 11:16:54.959620] <information> mirserver: Found rendering driver: mir:egl-generic (version 2.15.0)
[2023-10-03 11:16:54.959658] <information> mirserver: Driver supports:
[2023-10-03 11:16:54.959669] <information> mirserver:   System (priority 192)
[2023-10-03 11:16:54.959684] <information> mirserver: Found rendering driver: mir:virt (version 2.15.0)
[2023-10-03 11:16:54.959750] <information> mirserver: Found rendering driver: mir:x11 (version 2.15.0)
[2023-10-03 11:16:54.959830] <information> mirserver: Found rendering driver: mir:stub-graphics (version 2.15.0)
[2023-10-03 11:16:54.959847] <information> mirserver: Driver supports:
[2023-10-03 11:16:54.959859] <information> mirserver:   System (priority 1)
[2023-10-03 11:16:54.959903] <information> mirserver: Selected rendering driver: mir:egl-generic (version 2.15.0) for platform
ERROR: /root/parts/mir/src/src/server/graphics/default_configuration.cpp(375): Throw in function virtual const std::vector<std::shared_ptr<mir::graphics::RenderingPlatform> >& mir::DefaultServerConfiguration::the_rendering_platforms()
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: Exception while creating rendering platform
ERROR: /root/parts/mir/src/src/platforms/virtual/graphics/platform.cpp(46): Throw in function virtual void* mir::graphics::virt::Platform::VirtualDisplayInterfaceProvider::maybe_create_interface(const mir::graphics::DisplayInterfaceBase::Tag&)::StubGenericEGLDisplayProvider::get_egl_display()
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: Failed to initialize EGL display
$ miriway --virtual-output 800x600 --virtual-output 1200x900 --platform-display-libs=mir:virt --platform-rendering-libs=mir:virt
Info: wayland endpoint 'wayland-0' already exists, using it as host
[2023-10-03 11:19:40.177696] <information> mirserver: Starting
[2023-10-03 11:19:40.194233] < - debug - > mirserver: Not using logind for session management: Logind TakeControl call failed: GDBus.Error:System.Error.EBUSY: Device or resource busy
[2023-10-03 11:19:40.194428] < - debug - > mirserver: Not using Linux VT subsystem for session management: Failed to find the current VT
[2023-10-03 11:19:40.194444] < - debug - > mirserver: No session management supported
[2023-10-03 11:19:40.194490] <information> VT switch key handler: No VT switching support available: MinimalConsoleServices does not support VT switching
[2023-10-03 11:19:40.194906] <information> mircommon: Loading modules from: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform
[2023-10-03 11:19:40.195096] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-eglstream-kms.so.20
[2023-10-03 11:19:40.195186] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.20
[2023-10-03 11:19:40.195214] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-wayland.so.20
[2023-10-03 11:19:40.195237] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/renderer-egl-generic.so.20
[2023-10-03 11:19:40.195258] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-virtual.so.20
[2023-10-03 11:19:40.195280] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-x11.so.20
[2023-10-03 11:19:40.195299] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-evdev.so.8
[2023-10-03 11:19:40.195319] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-dummy.so
[2023-10-03 11:19:40.195342] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-stub.so
[2023-10-03 11:19:40.196666] <information> mirserver: Found display driver: mir:virt (version 2.15.0)
[2023-10-03 11:19:40.196693] <information> mirserver: Driver supports:
[2023-10-03 11:19:40.196719] <information> mirserver:   System (priority 192)
[2023-10-03 11:19:40.196758] <information> mirserver: Selected display driver: mir:virt (version 2.15.0) for platform
[2023-10-03 11:19:40.196947] <information> mircommon: Loading modules from: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform
[2023-10-03 11:19:40.197106] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-eglstream-kms.so.20
[2023-10-03 11:19:40.197134] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.20
[2023-10-03 11:19:40.197155] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-wayland.so.20
[2023-10-03 11:19:40.197178] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/renderer-egl-generic.so.20
[2023-10-03 11:19:40.197196] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-virtual.so.20
[2023-10-03 11:19:40.197215] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-x11.so.20
[2023-10-03 11:19:40.197237] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-evdev.so.8
[2023-10-03 11:19:40.197254] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-dummy.so
[2023-10-03 11:19:40.197269] <information> mircommon: Loading module: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/input-stub.so
[2023-10-03 11:19:40.198459] <information> mirserver: Found rendering driver: mir:virt (version 2.15.0)
ERROR: /root/parts/mir/src/src/server/graphics/default_configuration.cpp(375): Throw in function virtual const std::vector<std::shared_ptr<mir::graphics::RenderingPlatform> >& mir::DefaultServerConfiguration::the_rendering_platforms()
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: Exception while creating rendering platform
ERROR: /root/parts/mir/src/src/common/sharedlibrary/shared_library.cpp(73): Throw in function void* mir::SharedLibrary::load_symbol(const char*, const char*) const
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: /snap/miriway/1667/usr/lib/x86_64-linux-gnu/mir/server-platform/server-virtual.so.20: undefined symbol: probe_rendering_platform, version MIR_GRAPHICS_PLATFORM_2.8

So not getting very far

src/platforms/virtual/graphics/display.h Outdated Show resolved Hide resolved
src/platforms/virtual/graphics/display.h Outdated Show resolved Hide resolved
src/platforms/virtual/graphics/display.h Outdated Show resolved Hide resolved
@Saviq
Copy link
Collaborator

Saviq commented Oct 11, 2023

Couple issues in CI resulting from the extra platform that gets loaded.

In mir-smoke-test-runner in CI… I'm not sure what display platform is used today… will try and look. But maybe we should force it to virtual in that environment?

Could we keep the actual platform name virtual? virt suggests to me something to do with libvirt

Detected modules are: 
        mir:wayland
        mir:egl-generic
        mir:x11
        mir:gbm-kms
        mir:eglstream-kms
        mir:virt
        mir:stub-graphics
        throw-on-creation

@mattkae
Copy link
Contributor Author

mattkae commented Oct 11, 2023

Couple issues in CI resulting from the extra platform that gets loaded.

In mir-smoke-test-runner in CI… I'm not sure what display platform is used today… will try and look. But maybe we should force it to virtual in that environment?

Could we keep the actual platform name virtual? virt suggests to me something to do with libvirt

Detected modules are: 
        mir:wayland
        mir:egl-generic
        mir:x11
        mir:gbm-kms
        mir:eglstream-kms
        mir:virt
        mir:stub-graphics
        throw-on-creation

Yup, we can call it virtual! We have want to keep the namespace as virt or something else though, since it's a keyword

@mattkae
Copy link
Contributor Author

mattkae commented Oct 11, 2023

@Saviq The reason for the CI failure is that:

  • The virtual platform appears in the "supported" list before the X11 platform, and we appear to select the first supported one
  • The X11 input platform gets chosen because it is supported

A fix for this could be to make the virtual platform a "dummy" platform, so that it always has lesser priority than X11. To be honest, I can't think of a situation where you would want to default to a virtual platform

@Saviq
Copy link
Collaborator

Saviq commented Oct 11, 2023

@Saviq The reason for the CI failure is that:

  • The virtual platform appears in the "supported" list before the X11 platform, and we appear to select the first supported one
  • The X11 input platform gets chosen because it is supported

Right, so that's what I don't get… where does the X server come from? :)

A fix for this could be to make the virtual platform a "dummy" platform, so that it always has lesser priority than X11. To be honest, I can't think of a situation where you would want to default to a virtual platform

Don't think that'd be DTRT, see #3071 for how I think we could handle x11/wayland. Wouldn't virtual be a good default platform when headless? Though you said it's only ever used if --virtual_output is passed?

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Merging #3056 (634c940) into main (9404475) will decrease coverage by 0.02%.
The diff coverage is 75.15%.

@@            Coverage Diff             @@
##             main    #3056      +/-   ##
==========================================
- Coverage   78.45%   78.43%   -0.02%     
==========================================
  Files        1064     1073       +9     
  Lines       74434    74717     +283     
==========================================
+ Hits        58394    58604     +210     
- Misses      16040    16113      +73     
Files Coverage Δ
src/platforms/virtual/display_configuration.h 100.00% <100.00%> (ø)
src/platforms/virtual/platform.h 100.00% <100.00%> (ø)
src/platforms/x11/graphics/platform.cpp 100.00% <100.00%> (+9.67%) ⬆️
...sts/unit-tests/platforms/virtual/test_platform.cpp 100.00% <100.00%> (ø)
...ests/unit-tests/platforms/virtual/test_display.cpp 95.91% <95.91%> (ø)
examples/miral-shell/spinner/miregl.cpp 78.26% <63.63%> (-3.85%) ⬇️
src/platforms/virtual/graphics.cpp 63.63% <63.63%> (ø)
...latforms/common/server/options_parsing_helpers.cpp 81.25% <81.25%> (ø)
src/platforms/virtual/display.cpp 47.82% <47.82%> (ø)
src/platforms/virtual/display_configuration.cpp 56.66% <56.66%> (ø)
... and 1 more

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Saviq
Copy link
Collaborator

Saviq commented Oct 12, 2023

A fix for this could be to make the virtual platform a "dummy" platform, so that it always has lesser priority than X11. To be honest, I can't think of a situation where you would want to default to a virtual platform

Don't think that'd be DTRT, see #3071 for how I think we could handle x11/wayland. Wouldn't virtual be a good default platform when headless? Though you said it's only ever used if --virtual_output is passed?

So this confirms what I thought - we shouldn't make it dummy, because it will be dropped if we load any non-dummy platforms:
https://github.com/MirServer/mir/blob/aa0a7e08d365459d36516504d219964e715c744a/src/server/graphics/platform_probe.cpp#L187-L204

@AlanGriffiths
Copy link
Contributor

Don't think that'd be DTRT, see #3071 for how I think we could handle x11/wayland. Wouldn't virtual be a good default platform when headless? Though you said it's only ever used if --virtual_output is passed?

So this confirms what I thought - we shouldn't make it dummy, because it will be dropped if we load any non-dummy platforms:

Agreed, the virtual platform shouldn't be dummy but shouldn't be supported unless configured. (The wayland platform does this by checking for wayland-host.)

@Saviq
Copy link
Collaborator

Saviq commented Oct 12, 2023

Right, so that's what I don't get… where does the X server come from? :)

Aha!

https://github.com/MirServer/mir/blob/aa0a7e08d365459d36516504d219964e715c744a/tests/performance-tests/CMakeLists.txt#L34-L43

I've pushed what we should make work instead.

@Saviq
Copy link
Collaborator

Saviq commented Oct 12, 2023

I've pushed what we should make work instead.

Oh. Didn't expect it to actually work XD.

@AlanGriffiths
Copy link
Contributor

Why does the example above specify multiple outputs when wayvnc doesn't support this: "If the Wayland session consists of multiple outputs, only one will be captured."?

Do we know of a VNC server that does?

@Saviq
Copy link
Collaborator

Saviq commented Oct 12, 2023

Why does the example above specify multiple outputs when wayvnc doesn't support this: "If the Wayland session consists of multiple outputs, only one will be captured."?

Do we know of a VNC server that does?

You can --output Virtual-1

@Saviq Saviq force-pushed the feature/virtual_output_support branch from 439b8fc to 71902f0 Compare October 12, 2023 10:04
@Saviq
Copy link
Collaborator

Saviq commented Oct 12, 2023

Oh. Didn't expect it to actually work XD.

Ah. But it didn't actually run the performance or smoke tests… /me dislikes cmake_dependent_option.

src/platforms/virtual/graphics/display.cpp Outdated Show resolved Hide resolved
src/platforms/virtual/graphics/CMakeLists.txt Outdated Show resolved Hide resolved
Comment on lines 75 to 79
result.push_back({
nullptr,
mg::PlatformPriority::supported,
nullptr
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only execute if options.is_set(virtual_displays_option_name)

Comment on lines 60 to 63
(virtual_displays_option_name,
boost::program_options::value<std::vector<std::string>>()
->default_value(std::vector<std::string>{"1280x1024"}, "1280x1024")
->multitoken(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be setting a default: the user needs to explicitly request the virtual platform.

We likely also need options to specify them as "disconnected" (or that they should be "unused" on startup).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We likely also need options to specify them as "disconnected" (or that they should be "unused" on startup).

Can't be disconnected, can it, as how we'd connect them again? Unused? If you've enabled it through --virtual-output, why would you not use it? You can always have it disabled in your display layouts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about the "dynamically add a virtual output to serve to a tablet" scenario. But we agreed this could land without making that simple.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about the "dynamically add a virtual output to serve to a tablet" scenario.

Right, but to close that loop we'd need some means of connecting the disconnected outputs, which IMO is out of scope here. In fact, I think for that use case we should be creating / destroying virtual outputs, when we get to it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user still has to explicitly request the virtual platform (via --platform-display-libs=mir:virtual). When that is specified, we give them a default virtual output.

Right, but then they have to know to also add gbm-kms, or whatever else platform is appropriate.

Are you saying that the existence of a --virtual-output option should drive whether nor not we support a virtual platform instead?

Yes, same like --wayland-host is handled:

https://github.com/MirServer/mir/blob/7aa25d21141872b2edaf391f68cdc46590873681/src/platforms/wayland/platform_symbols.cpp#L60-L72

@Saviq
Copy link
Collaborator

Saviq commented Oct 12, 2023

Ah. But it didn't actually run the performance or smoke tests…

Better now. So this is what we need to fix:

72/83 Test #72: mir-smoke-test-runner ............................................................................................................***Failed    0.79 sec
# ...
[2023-10-12 10:14:20.235778] <information> mirserver: Selected display driver: mir:virtual (version 2.15.0) for platform
# ...
[2023-10-12 10:14:20.238083] <information> mirserver: Selected rendering driver: mir:egl-generic (version 2.15.0) for platform
ERROR: /home/runner/work/mir/mir/src/server/graphics/default_configuration.cpp(383): Throw in function virtual const std::vector<std::shared_ptr<mir::graphics::RenderingPlatform> >& mir::DefaultServerConfiguration::the_rendering_platforms()
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: Exception while creating rendering platform
ERROR: /home/runner/work/mir/mir/src/platforms/virtual/graphics/platform.cpp(47): Throw in function virtual void* mir::graphics::virt::Platform::VirtualDisplayInterfaceProvider::maybe_create_interface(const mir::graphics::DisplayInterfaceBase::Tag&)::StubGenericEGLDisplayProvider::get_egl_display()
Dynamic exception type: boost::wrapexcept<std::runtime_error>
std::exception::what: Failed to initialize EGL display

We should be able to use this with llvmpipe, no? That'd be the fully headless / software case, equivalent to xvfb-run.

@mattkae
Copy link
Contributor Author

mattkae commented Oct 12, 2023

Bug

  • If you run with --virtual-output=1280x1024 , both X11 and virtual will be supported, but this leads X11 to break

@mattkae
Copy link
Contributor Author

mattkae commented Oct 12, 2023

Everything is working on the box 🎉 I have updated comments on how to test there.

X11 is still broken, but I made this ticket to deal with it at a later time: #3076

@Saviq Saviq force-pushed the feature/virtual_output_support branch from a24ccce to c37b028 Compare October 13, 2023 05:48
@mattkae
Copy link
Contributor Author

mattkae commented Oct 23, 2023

@mattkae having talked through this, implementing a CPUAddressableDisplayProvider should get us in a better state here, would you please get a stab at this?

@mattkae the other thing (Chris mentions, but Michael doesn't) is that we shouldn't return a GenericEGLDisplayProvider when we can't initialize EGL: those checks need moving out of get_egl_display() into maybe_create_interface()

Understood!

@mattkae
Copy link
Contributor Author

mattkae commented Oct 23, 2023

@Saviq This doesn't work for me when the platform is X11:

MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 ./bin/miral-shell --virtual-output=800x600 --add-wayland-extensions=zwlr_screencopy_manager_v1:zwlr_virtual_pointer_manager_v1:zwp_virtual_keyboard_manager_v1

We're probably running into some ordering issue here. I get:

Dynamic exception type: boost::wrapexcept<std::system_error>
std::exception::what: Failed to create EGL context: EGL_BAD_CONTEXT (0x3006)

@Saviq
Copy link
Collaborator

Saviq commented Oct 23, 2023

@Saviq This doesn't work for me when the platform is X11:

MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 ./bin/miral-shell --virtual-output=800x600 --add-wayland-extensions=zwlr_screencopy_manager_v1:zwlr_virtual_pointer_manager_v1:zwp_virtual_keyboard_manager_v1

@AlanGriffiths does this work for you? Getting both virtual and x11 outputs?

We're probably running into some ordering issue here. I get:

I don't think we have any ordering problems any more…

I'll try in a couple additional setups, too.

@AlanGriffiths
Copy link
Contributor

@AlanGriffiths does this work for you? Getting both virtual and x11 outputs?

No:

$ MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 cmake-build-debug/bin/mir_demo_server --virtual-output=800x600
...
ERROR: /root/parts/mir/src/src/platforms/x11/graphics/egl_helper.cpp(223): Throw in function std::unique_ptr<mir::graphics::X::helpers::Framebuffer> mir::graphics::X::helpers::EGLHelper::framebuffer_for_window(const mir::graphics::GLConfig&, xcb_connection_t*, xcb_window_t, EGLContext)
Dynamic exception type: boost::wrapexcept<std::system_error>
std::exception::what: Failed to create EGL context: EGL_BAD_CONTEXT (0x3006)

sh: 1: /usr/share/apport/recoverable_problem: not found
double free or corruption (fasttop)
Aborted

FWIW the platforms selected are as expected:

$ MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 cmake-build-debug/bin/mir_demo_server --virtual-output=800x600 2>&1 | grep Selected
[2023-10-23 17:41:02.444789] <information> mirserver: Selected display driver: mir:virtual (version 2.15.0) for platform
[2023-10-23 17:41:02.444953] <information> mirserver: Selected display driver: mir:x11 (version 2.15.0) for platform
[2023-10-23 17:41:02.493002] <information> mirserver: Selected rendering driver: mir:egl-generic (version 2.15.0) for platform
[2023-10-23 17:41:02.547357] <information> mirserver: Selected input driver: mir:x11-input (version: 2.15.0)

But this difference in experience is likely because of the order display drivers are tried. @mattkae if you try the last incantation, which order are the drivers listed for you?

@mattkae
Copy link
Contributor Author

mattkae commented Oct 23, 2023

Bug: For some reason, SpinnerSplash is not joining when we stop with a virtual platform only

Update: MirEglSurface::swap_buffers is the culprit

Update 2: If you run a VNC, it breaks through that section and closes normally. It looks like we don't have a Renderer immediately in the virtual case (as we do in other cases). This appears to somehow be causing the eglSwapBuffers call to hang

Update 3: Oof I see! We have no DisplayBuffers, so we never create a compositor for the buffer and then we never make a Renderer. The swap_buffers call gets completed when we do a Renderer::render call (specifically GLRenderingProvider::as_texture causes it to move forward, even more specifically via DmabufTexBuffer::as_texture when on_conumed is called).

@Saviq
Copy link
Collaborator

Saviq commented Oct 23, 2023

But this difference in experience is likely because of the order display drivers are tried.

Indeed, mine has x11 first:

$ MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 build-Debug/bin/mir_demo_server --virtual-output=800x600 2>&1 | grep Selected
[2023-10-23 20:00:36.718442] <information> mirserver: Selected display driver: mir:x11 (version 2.15.0) for platform
[2023-10-23 20:00:36.736904] <information> mirserver: Selected display driver: mir:virtual (version 2.15.0) for platform
[2023-10-23 20:00:36.751231] <information> mirserver: Selected rendering driver: mir:egl-generic (version 2.15.0) for platform
[2023-10-23 20:00:36.757192] <information> mirserver: Selected rendering driver: mir:gbm-kms (version 2.15.0) for device ((null): /dev/dri/renderD128)
[2023-10-23 20:00:36.773103] <information> mirserver: Selected input driver: mir:x11-input (version: 2.15.0)

@mattkae
Copy link
Contributor Author

mattkae commented Oct 23, 2023

MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 build-Debug/bin/mir_demo_server --virtual-output=800x600 2>&1 | grep Selected

Makes sense! And on my system:

[14:42:35] ~/Github/mir/build (feature/virtual_output_support) $ MIR_EXPERIMENTAL_HYBRID_GRAPHICS=1 WAYLAND_DISPLAY=wayland-1 ./bin/mir_demo_server --virtual-output=800x600 2>&1 | grep Selected
[2023-10-23 14:42:40.878002] <information> mirserver: Selected display driver: mir:virtual (version 2.15.0) for platform
[2023-10-23 14:42:40.878202] <information> mirserver: Selected display driver: mir:x11 (version 2.15.0) for platform
[2023-10-23 14:42:40.968378] <information> mirserver: Selected rendering driver: mir:egl-generic (version 2.15.0) for platform
[2023-10-23 14:42:40.979132] <information> mirserver: Selected rendering driver: mir:gbm-kms (version 2.15.0) for device ((null): /dev/dri/renderD129)
[2023-10-23 14:42:41.013873] <information> mirserver: Selected input driver: mir:x11-input (version: 2.15.0)
[14:42:41] ~/Github/mir/build (feature/virtual_output_support) $ 

@mattkae
Copy link
Contributor Author

mattkae commented Oct 23, 2023

@Saviq @AlanGriffiths Would it be worth it to investigate the ordering as part of this task? Or is that better left for a future task?

@Saviq
Copy link
Collaborator

Saviq commented Oct 23, 2023

@Saviq @AlanGriffiths Would it be worth it to investigate the ordering as part of this task? Or is that better left for a future task?

I think separate, but @RAOF do you think there's anything more the virtual platform can do here?

@RAOF
Copy link
Contributor

RAOF commented Oct 24, 2023

@Saviq @AlanGriffiths Would it be worth it to investigate the ordering as part of this task? Or is that better left for a future task?

I think separate, but @RAOF do you think there's anything more the virtual platform can do here?

I don't think there's anything more the virtual platform can really do here.

Copy link
Contributor

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few trivial tweaks. Will push fix

examples/miral-shell/spinner/miregl.cpp Outdated Show resolved Hide resolved
examples/miral-shell/spinner/miregl.h Outdated Show resolved Hide resolved
src/platforms/virtual/graphics.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy now

@Saviq
Copy link
Collaborator

Saviq commented Oct 24, 2023

 ../../../../examples/miral-shell/spinner/miregl.cpp:217:24: error: unused variable ‘done’ [-Werror=unused-variable]
  217 |             auto const done = cv.wait_for(lock, std::chrono::milliseconds{100}, [this]{ return posted; });
      |                        ^~~~

@AlanGriffiths AlanGriffiths added this pull request to the merge queue Oct 24, 2023
Merged via the queue into main with commit 4a57bc6 Oct 24, 2023
33 checks passed
@AlanGriffiths AlanGriffiths deleted the feature/virtual_output_support branch October 24, 2023 15:43
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 this pull request may close these issues.

4 participants