Repository navigation
Conversation
|
This is a straight-forward enough change, but I'm not 100% confident it is the correct thing to do. It does, however, fix the issue I was encountering. |
|
I believe #112 is more appropriate to fix your immediate issue (leak when keeping element in PAUSED), can you give it a spin and report please? |
|
I had Claude do testing of this locally. I can definitely confirm that there were some crashes involved as they triggered macOS crash reports. I hate giving people raw AI outputs, but I've attempted to at least get this as clear and concise as possible. I've read through it all and it makes sense to me. But I am also very new to this codebase.
|
|
heh, lots of words to point out the audio check is in the wrong place :D |
cefsrc is a live element, and shouldn't queue any data until it has reached the PLAYING state. See #111
|
@MathieuDuponchelle true! |
cefsrc is a live element, and shouldn't queue any data until it has reached the PLAYING state. See #111
RenderHandler::OnPaint allocates a full frame (width * height * 4) and appends it to src->queue on every paint in PLAYING. The only consumer, gst_cef_src_create(), runs on the streaming task, so if that task stops while the element stays in PLAYING -- for example after GST_FLOW_NOT_NEGOTIATED -- the queue grows by 8.3 MB per paint at 1080p. A leaky queue downstream does not help, since create() is not being called at all. On macOS CEF installs PartitionAlloc process-wide, so the allocation failure is a CHECK abort inside OnPaint rather than a NULL return. Cap the queue at two frames and drop the oldest, matching the single-frame latency the element advertises. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
OnAudioStreamPacket appends to src->audio_buffers without a limit. The list is drained by the same gst_cef_src_create() call as the frame queue, so it grows the same way once the streaming task stops. Drop the oldest packets past 128; the list is emptied on every video frame and normally holds a handful. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
f464c7e to
68d730e
Compare
RenderHandler::OnPaintallocates a full frame and appends it tosrc->queueon every paint. Since #112 it discards frames in PAUSED, but in PLAYING it still queues unconditionally, and the only consumer isgst_cef_src_create()on the streaming task. If that task stops while the element stays in PLAYING, the queue grows bywidth * height * 4bytes per paint (8.3 MB at 1080p) until the process runs out of memory.We hit this when downstream caps pinned a framerate that
cefsrc's0/1could not satisfy:gst_base_src_looppaused the task onGST_FLOW_NOT_NEGOTIATED, the pipeline stayed in PLAYING, and the browser kept painting. A leaky queue downstream does not prevent this, sincecreate()is not being called and the queue forwardsNOT_NEGOTIATEDupstream anyway. On macOS CEF installs PartitionAlloc process-wide, so the failed allocation aborts insideOnPaintinstead of returning NULL.Changes
create()pops one frame per paint, so the cap only engages once draining has stopped.src->audio_buffersat 128 and drop the oldest packets. It is drained by the samecreate()call and normally holds a handful.The commits are independent. #105 is orthogonal: with it the queue stays at one frame and this cap never engages.
Testing
macOS/arm64, CEF 144.0.21, GStreamer 1.28.6; this branch and master built side by side. The page animates a 1920×1080 canvas and plays a WebAudio tone. Memory is
phys_footprint, sampled once a second.Task stopped in PLAYING.
cefsrc ! video/x-raw,framerate=30/1 ! fakesinkfails withNOT_NEGOTIATEDwhile the element stays in PLAYING.Normal playback.
cefsrc ! cefdemuxwith both pads intofakesinkfor 30 s: 928 paints, frame queue and audio list never above 1, nothing dropped.cefsrc ! fakesinklikewise dropped nothing.Not run on Linux or Windows. The repo has no automated tests, so there is no regression test.
Crash evidence
Two aborts ~3h apart with identical stacks:
OnPaint → gst_buffer_new_allocate → _sysmem_new_block → malloc → brk #0in CEF.x23 = 0x7E9097(1920×1080×4);x1 = 0xA00000, the 10 MiB chunk PartitionAlloc could not obtain.🤖 Generated with Claude Code