alert ticker: draw it inside the Stream Alerts box, not as a top-edge bar
Creator 2026-09-26: "the ticker should appear over the stream alerts video, not over
the entire preview window". It was a GLOBAL 1920x48 bar blitted last at a hardcoded
(0, 0) -- it covered the whole preview width, not the alert video.
The strip is now rendered at the alert box's own size and the box's origin travels on
the frame in a new VideoFrame.Placement ((int X, int Y)?). OriginX/OriginY default to
0 when Placement is null, so every full-canvas overlay (the branding flash) is
unaffected. Every ticker blit site now reads tickerFrame.OriginX/OriginY instead of a
literal 0, 0 -- SceneCompositor x2 and FramePump's static-bake Overlay path -- and
PreviewPane.xaml's AlertTickerElement binds the same rect (AlertTickerLeft/Top/
Width/Height), so the preview cannot drift from the recording the creator is judging.
Why the position rides on the frame rather than in a full-canvas frame: a 1920x1080
overlay is 8.3MB of large-object-heap garbage per tick, ~2.5GB churned over one 10s
alert at 30fps. A box-sized strip is ~370KB. The branding flash does render
full-canvas but RECYCLES one 8MB buffer and bumps Epoch, so it never allocates per
frame; the ticker allocates per call, so it has to stay small.
Also fixed: CopyStrip now clips ROWS to the target height. The pill rasterises at its
natural 48px, so an alert box shorter than that would have written past the end of the
target buffer once the strip became box-sized.
No alert box in the scene now means no ticker at all -- there is no global position
left for it, and this is the guard against the old bar quietly coming back.
Tests (3 new facts, 27 in the file):
ComposedOutput_PutsTheTickerInsideTheAlertBox_NotAtTheTopEdge -- renders through
the real SceneCompositor and asserts the pixels land at (620, 430) and NOT at the
top-left corner. The creator is judging compositing from local recordings, so the
OUTPUT side is the side that needed proving.
ASceneWithNoAlertBox_PublishesNoTicker
ABoxShorterThanTheStrip_ClipsRowsInsteadOfOverrunning
Updated AlertLayer_PublishesARealTickerFrameToThePreviewSink, which asserted the old
1920 width from a box with no geometry (defaulted to 1px); it now uses the product's
own default box (680x200 at 620,430, MainViewModel.Sources.cs:54-57) and pins the
frame size and origin.
Full suite 367/367.
This commit is contained in:
@@ -18,6 +18,11 @@ namespace ytLive.Tests;
|
||||
/// TASK 47 Good Dog (take four, 2026-09-26): the alert announcement strip must be
|
||||
/// DRAWN by the preview pane, in all three display methods, at a pace that is
|
||||
/// actually readable.
|
||||
/// <para><b>take five, 2026-09-26 (creator ruling):</b> the strip is no longer a global
|
||||
/// 1920px bar at the top of the frame — it draws INSIDE the Stream Alerts box, "over the
|
||||
/// stream alerts video, not over the entire preview window". The frame is box-sized and
|
||||
/// carries the box's origin on <see cref="VideoFrame.Placement"/>; the preview element
|
||||
/// and every compositor blit site read that origin instead of a hardcoded 0.</para>
|
||||
/// <para>The bug: the strip is a global 1920x48 overlay that existed only as a frame-
|
||||
/// pump callback (<c>alertTicker: () => _alertLayer.AlertTickerFrame</c>), so it
|
||||
/// reached the stream and never the pane the creator watches — the same class of
|
||||
@@ -62,7 +67,7 @@ public sealed class AlertTickerPreviewDisplayTests
|
||||
var holder = Find(pane, e => e is FrameworkElement f
|
||||
&& f.Name == "AlertTickerElement") as FrameworkElement;
|
||||
Assert.True(holder != null,
|
||||
"PreviewPane.xaml has no AlertTickerElement — the strip is global, so it needs its own root, not a Source's Image");
|
||||
"PreviewPane.xaml has no AlertTickerElement — the strip needs its own root, not a Source's Image");
|
||||
Assert.Equal(Visibility.Visible, holder!.Visibility);
|
||||
|
||||
var image = Find(holder, e => e is Image) as Image;
|
||||
@@ -111,6 +116,14 @@ public sealed class AlertTickerPreviewDisplayTests
|
||||
Type = SourceType.AlertBox,
|
||||
AlertShowTicker = true,
|
||||
AlertDisplayMethod = method,
|
||||
// The product's own default for a new alert box
|
||||
// (MainViewModel.Sources.cs:54-57) — 680x200 at (620, 430).
|
||||
// A box with no geometry defaulted to 1px, which is what made
|
||||
// this assertion read 1920 before the strip became box-sized.
|
||||
X = 620,
|
||||
Y = 430,
|
||||
Width = 680,
|
||||
Height = 200,
|
||||
};
|
||||
var scene = new Scene { Name = "Live" };
|
||||
scene.Elements.Add(box);
|
||||
@@ -125,8 +138,15 @@ public sealed class AlertTickerPreviewDisplayTests
|
||||
|
||||
var frame = published.LastOrDefault();
|
||||
Assert.True(frame != null, $"{method}: the layer published no ticker frame to the preview");
|
||||
Assert.Equal(1920, frame!.Width);
|
||||
// CREATOR RULING 2026-09-26: the strip draws INSIDE the Stream
|
||||
// Alerts box — "over the stream alerts video, not over the entire
|
||||
// preview window". So the frame is the box's width and carries the
|
||||
// box's origin; the height stays the natural 48px strip, pinned to
|
||||
// the top of the (200px tall) box.
|
||||
Assert.Equal(680, frame!.Width);
|
||||
Assert.Equal(48, frame.Height);
|
||||
Assert.Equal(620, frame.OriginX);
|
||||
Assert.Equal(430, frame.OriginY);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -342,6 +362,105 @@ public sealed class AlertTickerPreviewDisplayTests
|
||||
&& c.Items.OfType<ComboBoxItem>().Any(i => (string)i.Content == "Scroll")
|
||||
&& c.Items.OfType<ComboBoxItem>().Any(i => (string)i.Content == "Solid")) as ComboBox;
|
||||
|
||||
/// <summary>CREATOR RULING 2026-09-26, the OUTPUT side: "the ticker should appear
|
||||
/// over the stream alerts video, not over the entire preview window". The creator is
|
||||
/// judging compositing from local recordings, so this renders through the real
|
||||
/// compositor and asserts where the pixels actually land: inside the alert box at
|
||||
/// (620, 430), and NOT at the top-left corner where the old global strip sat.</summary>
|
||||
[Fact]
|
||||
public void ComposedOutput_PutsTheTickerInsideTheAlertBox_NotAtTheTopEdge()
|
||||
{
|
||||
const int boxX = 620, boxY = 430, boxW = 680, boxH = 48;
|
||||
|
||||
// A solid opaque slab, so "did it composite here?" is a one-pixel question.
|
||||
var slab = new byte[boxW * boxH * 4];
|
||||
for (var i = 0; i < slab.Length; i += 4)
|
||||
{
|
||||
slab[i] = 0; slab[i + 1] = 255; slab[i + 2] = 0; slab[i + 3] = 255; // green
|
||||
}
|
||||
var ticker = new VideoFrame(boxW, boxH, slab) { Placement = (boxX, boxY) };
|
||||
|
||||
var options = new CompositorOptions
|
||||
{
|
||||
SourceRectX = 0,
|
||||
SourceRectY = 0,
|
||||
SourceRectWidth = 1920,
|
||||
SourceRectHeight = 1080,
|
||||
OutputWidth = 1920,
|
||||
OutputHeight = 1080,
|
||||
};
|
||||
var outFrame = new SceneCompositor().Render(
|
||||
new Scene { Name = "Live" },
|
||||
_ => null,
|
||||
flashFrame: null,
|
||||
options,
|
||||
tickerFrame: ticker);
|
||||
|
||||
Assert.True(IsGreen(outFrame, boxX, boxY),
|
||||
"the ticker is not in the alert box — the strip is no longer drawn over the "
|
||||
+ "Stream Alerts video");
|
||||
Assert.True(IsGreen(outFrame, boxX + boxW - 1, boxY + boxH - 1),
|
||||
"the ticker's far corner is missing from the alert box");
|
||||
Assert.False(IsGreen(outFrame, 0, 0),
|
||||
"the ticker is still a full-width bar at the top-left of the frame — it must "
|
||||
+ "sit inside the Stream Alerts box, not over the whole canvas");
|
||||
}
|
||||
|
||||
private static bool IsGreen(VideoFrame frame, int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= frame.Width || y >= frame.Height) return false;
|
||||
var i = (y * frame.Width + x) * 4;
|
||||
return frame.BgraPixels[i + 1] > 200 && frame.BgraPixels[i + 3] > 200;
|
||||
}
|
||||
|
||||
/// <summary>With the strip living inside the alert box, a scene with NO alert box
|
||||
/// has nowhere to put it — so there must be no ticker at all. This is the guard
|
||||
/// against the old global strip quietly coming back.</summary>
|
||||
[Fact]
|
||||
public void ASceneWithNoAlertBox_PublishesNoTicker()
|
||||
{
|
||||
_app.Run(() =>
|
||||
{
|
||||
var layer = new AlertOverlayLayer(new AlertRenderer(), tickerPreviewSink: _ => { });
|
||||
var scene = new Scene { Name = "Live" };
|
||||
scene.Elements.Add(new Source { Name = "Bg", Type = SourceType.Background });
|
||||
|
||||
layer.OnMessageReceived(new ChatMessage
|
||||
{
|
||||
AuthorName = "Funder",
|
||||
Kind = ChatEventKind.SuperChat,
|
||||
SuperChatDisplayString = "$10.00",
|
||||
}, new[] { scene });
|
||||
|
||||
Assert.Null(layer.AlertTickerFrame);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>A short alert box must clip the strip's rows, not overrun the target
|
||||
/// buffer. The strip rasterises at its natural 48px, so a 20px-tall box used to be
|
||||
/// a heap-corrupting write once the strip was composited at the box's size.</summary>
|
||||
[Fact]
|
||||
public void ABoxShorterThanTheStrip_ClipsRowsInsteadOfOverrunning()
|
||||
{
|
||||
var box = new Source
|
||||
{
|
||||
Name = "Stream Alerts",
|
||||
Type = SourceType.AlertBox,
|
||||
AlertShowTicker = true,
|
||||
X = 620,
|
||||
Y = 430,
|
||||
Width = 680,
|
||||
Height = 20,
|
||||
};
|
||||
var frame = AlertTickerRenderer.Render(
|
||||
TickerText, 0.2, AlertDisplayMethod.Solid, ClipSeconds,
|
||||
readsPerAlert: 3, width: 680, height: 20);
|
||||
|
||||
Assert.NotNull(frame);
|
||||
Assert.Equal(680, frame!.Width);
|
||||
Assert.Equal(20 * 680 * 4, frame.BgraPixels.Length);
|
||||
}
|
||||
|
||||
private static DependencyObject? Find(DependencyObject parent, Func<DependencyObject, bool> predicate)
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
||||
|
||||
Reference in New Issue
Block a user