feat(cef): expose frame IOSurface id to Dart for WebRTC streaming#12
Merged
Conversation
Add CefWebController.getFrameSurface() + an onSurface callback (and the CefSurfaceInfo model) that surface the existing global IOSurface id, so a host app can IOSurfaceLookup the live OSR CVPixelBuffer and feed it to a libwebrtc RTCVideoSource — with no webrtc dependency in flutter_cef. onSurface fires on each (re)allocation so consumers re-resolve after a resize realloc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ceInfo The onSurface callback was effectively dead: it fired only from the init publish (before the plugin wired the callback) and never on resize (sendResize swaps the surface inline; promotion happens in handleFrame(opPresent)/the resize watchdog, neither of which called publishBuffers). So a consumer's resize re-point (R2) never triggered — after any resize the freed/stale surface kept being sampled. - Route both resize-promotion paths (opPresent + watchdog force-promote) through a notifySurface() helper so onSurface fires on every realloc. - Add emitCurrentSurface(); the plugin calls it right after wiring onSurface so the initial surface (whose publish predated the callback) is delivered. - Export CefSurfaceInfo from the public barrel (was unreferenceable by consumers). Now matches the documented "fires on init + each resize" contract. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
CefWebController.getFrameSurface()+ anonSurfacecallback (and theCefSurfaceInfomodel) that surface the existing global IOSurface id of the live OSRCVPixelBuffer.A host app can then
IOSurfaceLookupthat surface and feed it to a libwebrtcRTCVideoSource— with nowebrtcdependency added to flutter_cef.onSurfacefires on each (re)allocation, so consumers re-resolve after a resize realloc.This is the engine-side primitive behind streaming a live Chromium tile to remote peers / a mobile companion in the consumer app (work_canvas).
Changes
lib/src/cef_web_controller.dart—getFrameSurface()+onSurfacesetterlib/src/cef_events.dart—CefSurfaceInfo(surfaceId + physical w/h)macos/Classes/CefWebSession.swift— emit the surface id on alloc/reallocmacos/Classes/FlutterCefPlugin.swift— wire the channel event + getterNo
webrtcdep; additive API; existing behavior unchanged.🤖 Generated with Claude Code