Skip to content

Off-screen rendering with webview2 #547

Open

Description

@ajaymonga

Hi
Is it possible to get webview2 to render into a shared memory region like CEF :
https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-off-screen-rendering

In my application I use 2 process architecture where main process does not have network access and second process uses CEF to render webcontent into a shared memory region from where main app can read the pixels. I am wondering if I can achieve this using webview2

Thanks

AB#28491736

Activity

  1. champnic commented on Oct 20, 2020

    @champnic
    Member

    Currently this is not possible. We have offscreen rendering on our backlog, and are tracking it in #20, but I think this ask is clearer so I'll also add this issue to our item. Thanks!

  2. Harvey3141 commented on Oct 10, 2021

    @Harvey3141

    Hi, do you have any updates on this which you're able to share?

  3. champnic commented on Oct 11, 2021

    @champnic
    Member

    Unfortunately not yet. We have not begun work on this yet. This is a large amount of work, and while very high on our priority list, gets bumped each quarter as higher priority asks come in. I really want to do this work as it's currently one of our top asks, but the earliest that could happen is Q1 2022 at this point.

  4. avail commented on Apr 8, 2022

    @avail

    Any news on this?

  5. champnic commented on Apr 8, 2022

    @champnic
    Member

    We are starting on the design phase of this work. Would you mind sharing your use case so that we can consider it in our plans?

  6. doxxx commented on Apr 8, 2022

    @doxxx

    We are currently using CefSharp to render into an offscreen buffer that is sent to an FPGA to be composited onto a live video feed. The render includes playback of MPEG4-encoded video. We were looking into using WebView because CefSharp's default Chromium build does not include the MPEG4 codec. But without offscreen rendering, that's a moot point. We've since produced our own custom build of Chromium to include the codec.

  7. rjx-ray commented on Apr 13, 2022

    @rjx-ray

    Our use case is to show web content in our immersive VR spaces. See https://www.igloovision.com/software/enterprise-package/igloo-web

    We need access to the web rendered textures so that we can warp and blend multiple images to projector outputs to create a clear seamless view on the inside of a cylinder or room.

    Currently we use CEF for the web input with a user maintained patch for getting the shared textures. See https://bitbucket.org/chromiumembedded/cef/pull-requests/285 and read down to the end of the comments for full details. We build CEF with proprietary codecs included. The builds of our app and CEF are done with C++.

    This is unsatisfactory because it uses the deprecated custom compositing (which could be removed in future) instead of skia and is difficult to keep updated.

    We would look at moving to webview2 if access to the rendered textures could be provided and supported along with the ability to include proprietary codecs

  8. champnic commented on Apr 13, 2022

    @champnic
    Member

    Thanks for the info Richard Jackson (@rjx-ray)! If you don't need high-frequency rendering you could consider using the CapturePreview function to get an image, but this isn't great for things like videos or other animations.

  9. rjx-ray commented on Apr 13, 2022

    @rjx-ray

    Hi Nic Champagne Williamson [MSFT] (@champnic), thanks for the response but we do need high-frequency rendering, typically for YouTube and other web video display.

  10. avail commented on Apr 17, 2022

    @avail

    We are starting on the design phase of this work. Would you mind sharing your use case so that we can consider it in our plans?

    Game UI development, specifically within DirectX 9 (Ex) / 10 / 11 contexts.

    Ability to render into an offscreen texture and display that as overlay of the game.

  11. added
    tracked
    on May 10, 2022
  12. jcain82 commented on May 11, 2022

    @jcain82

    We are starting on the design phase of this work. Would you mind sharing your use case so that we can consider it in our plans?

    Currently, we utilize CefSharp Offscreen for generating a PDF from HTML content or using it to generate screenshots of HTML in a server side environment.

  13. 117 remaining items

  14. scalveerne commented on Mar 26, 2025

    @scalveerne

    Vladimir Ikryanov (@vladimir-ikryanov) The problem I have right now is that I am actually using a lib for Flutter that uses WebView2 inside, at this moment the selects do not work and according to the developer is because of the lack of this functionality.

    By any chance do you have any recommendation, it would be VERY useful indeed.

  15. vladimir-ikryanov commented on Apr 2, 2025

    @vladimir-ikryanov

    scalveerne Flutter doesn't use native Windows widgets to display UI. It just renders UI. So, all the buttons, labels, tables, are just pictures. When that lib embeds and displays a WebView2 control inside a Flutter window, the WebView2 is embedded as a child HWND native window. In this case you should observe that you cannot display Flutter message dialogs on top of WebView2. It's because Flutter cannot render its UI on top of a third-party native window that is displayed on top of Flutter's canvas where all the UI controls are rendered.

    By default, WebView2 should display the drop-down popups (selects) using its own functionality. In general, WebView2 will just ask Chromium (WebView2 uses Chromium underhood) to create and display the popup at specific location on screen. WebView2 should tell Chromium the locations of the WebView on screen, so that Chromium could locate the popup relatively.

    I suppose the lib, that embeds WebView2 inside a Flutter window, doesn't provide this info to WebView2 -> Chromium. That's why Chromium cannot display the drop-down popups (maybe it's displayed, but somewhere out of the screen or at 0x0 of the screen). Maybe WebView2 doesn't provide an API that the developer of the lib can use to do this. Maybe that's what they mean by "the lack of this functionality".

    Anyway, this issue can be solved only by the developer of the lib that allows embedding WebView2 inside Flutter. I don't know any possible way to fix or workaround this behavior outside the lib or inside your Flutter code. Sorry about that 🙁.

  16. scalveerne commented on Apr 2, 2025

    @scalveerne

    Vladimir Ikryanov (@vladimir-ikryanov) There were some concepts that I was not clear and thanks to your comment I think I understand them better, I will try to touch some things in the bookstore in the hope that something will change, I thank you very much for your comment, it was VERY useful and productive for me and my product.

  17. whiskets commented on Jun 17, 2025

    @whiskets

    Is off-screen rendering available for WebView2?

    right now l use cefsharp + opengl

  18. e-m-hh-com commented on Sep 2, 2025

    @e-m-hh-com

    Is there a roadmap for this functionality or will it never be available?

  19. or75 commented on Sep 15, 2025

    @or75

    is there any progress on this issue?

  20. gabereiser commented on Oct 13, 2025

    @gabereiser

    +1. Kicking this as it’s highly requested and could also improve my life.

  21. bwedding commented on Dec 5, 2025

    @bwedding

    We are starting on the design phase of this work. Would you mind sharing your use case so that we can consider it in our plans?

    Nic Champagne Williamson [MSFT] (@champnic) This was in April 2022. Any progress in the last 3-1/2 years?

  22. ItsCubeTime commented on Jan 7, 2026

    @ItsCubeTime

    #547 (comment)
    Can this be done with the win32 API somehow?

    Im thinking like, you create a window using CreateWindowEx & attach a webview to it using CreateCoreWebView2EnvironmentWithOptions ... then somehow read pixels directly from the window - without having to rely on any framework like winrt?

  23. castorix commented on Jan 8, 2026

    @castorix

    #547 (comment) Can this be done with the win32 API somehow?

    Im thinking like, you create a window using CreateWindowEx & attach a webview to it using CreateCoreWebView2EnvironmentWithOptions ... then somehow read pixels directly from the window - without having to rely on any framework like winrt?

    I did this in C++/Win32 or WinUI 3 C# +P/Invoke with COM interfaces (ICoreWebView2CompositionController and so on).
    But it was just to capture/draw a bitmap from Visual (with GDI and CreateDIBSection)
    It can be more complicated for live rendering (must be done with GPU, otherwise too slow...)
    I will have to try to check if GraphicsCaptureItem + Direct2D can be used...

  24. castorix commented on Jan 9, 2026

    @castorix

    I will have to try to check if GraphicsCaptureItem + Direct2D can be used...

    I tested with Direct2D and Direct3D (with IDirect3DDxgiInterfaceAccess to get Texture or Surface then ID2D1Bitmap1) in WinUI3 C# and it seems to work correctly.
    Test with Google page on a classic rotating cube in Direct3D 11 with a SwapChainPanel (animation is smoother than in the GIF, although not perfect on my old PC (no real GPU)) :

    Image

  25. castorix commented on Jan 19, 2026

    @castorix

    I uploaded a test sample in WinUI 3 C# + P/Invoke (like C++/Win32) : WinUI3_SwapChainPanel_WebView2
    by getting, from captured frames, ID2D1Bitmap1 for Direct2D or ID3D11Texture2D for Direct3D or other

  26. mdrejhon commented on Jan 19, 2026

    @mdrejhon

    I uploaded a test sample in WinUI 3 C# + P/Invoke (like C++/Win32) : WinUI3_SwapChainPanel_WebView2 by getting, from captured frames, ID2D1Bitmap1 for Direct2D or ID3D11Texture2D for Direct3D or other

    This is interesting! Although I am not sure if the frames of the browser is synchronized to the frames of requestAnimationFrame() for synchronized animations in the browser.

    Are you wiling to assign a permissive source code license such as MIT or Apache to it?

  27. castorix commented on Jan 20, 2026

    @castorix

    This is interesting! Although I am not sure if the frames of the browser is synchronized to the frames of requestAnimationFrame() for synchronized animations in the browser.

    Are you wiling to assign a permissive source code license such as MIT or Apache to it?

    I did not test with requestAnimationFrame; I can get a correct result (no dropped frames) on my old/slow PC with Microsoft.UI.Dispatching.DispatcherQueueTimer, although a thread should be used with other frameworks (not easy in WinUI 3 with classic RPC_E_WRONG_THREAD error without DispatcherQueue.TryEnqueue)

    All the code examples I upload in my repository can be copied/pasted or improved; I usually post them to answer questions on GitHub or Microsoft forums (previously (on Usenet, MSDN), I used to link to .zip files, but I was told that it was more practical and sustainable to upload code with GitHub now...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature requesttracked

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions