cefsimple offscreen rendering in macos

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

cefsimple offscreen rendering in macos

Postby linuxcef07 » Tue Jan 30, 2024 2:04 pm

I am running cefsimple in offscreen rendering mode in macos (ventura, arm64) and with this I am getting pixel buffer in OnPaint(). I have disabled gpu using "disable-gpu" switch in my code to avoid crashes in gpu process.
I have to pass this pixel buffer to another app (process) so I have created IOSurface and copied pixel buffer into it. Now, before passing it to another process I am trying to validate this IOSurface in cefsimple itself (by redering it on local window/NSview).
After running cefsimple with youtube url and with my rendering changes, I can hear audio but there is no video on NSView.
My OnPaint() implementation is something like below:
Code: Select all
void SimpleHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type,
                     const RectList &dirtyRects, const void* buffer,
                     int width, int height)
{
    if (type == PET_VIEW) {
         if (!ioSurface) //ioSurface is created in ctor
            ioSurface = CreateIOSurface(width, height);
        CopyPixelBufferToIOSurface(buffer, width, height, ioSurface);
        RenderOnLocalWindow(buffer, ioSurface);
}


and rendering code is as follow (using CALayer)
Code: Select all
 
     // Create a CALayer with IOSurface as its contents
     CALayer* surfaceLayer = [CALayer layer];
     
     // Set the IOSurface as the contents of the layer
     surfaceLayer.contents = (__bridge id)ioSurface;
     
     // Set layer bounds to match IOSurface dimensions
     surfaceLayer.bounds = CGRectMake(0, 0, width, height);
     
     // Add the layer to the NSView's layer
     [m_NSView setLayer:surfaceLayer];
     [m_NSView setWantsLayer:YES];


Log shows that I am getting pixel buffers for playing youtube video but somehow rendering video is not working. Do I need to use different framework for rendering?
Has anyone implemented this before? It would be great if someone could provide input on this.
linuxcef07
Techie
 
Posts: 34
Joined: Wed Dec 20, 2023 11:57 am

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 163 guests