Signal: detect the white speaking border (not a coloured one)

Signal's active-speaker cue is a 3px #ffffff rounded border (saturation ≈ 0),
which the saturation-based highlight detector could never see. Per the
Signal-Desktop source review:

- FrameSampler.thinWhitePoints: grid-sample near-white pixels that sit on a
  THIN structure (a non-white pixel within edgeGap on some axis) so a border/
  ring counts but a solid white blob (face, bright video) does not.
- GridCallAnalyzer: combine coloured (saturated) + white (thin) highlight
  pixels; exclude name-text regions so the white footer name can't be mistaken
  for the border; estimate the tile UP from the name footer (nameAtBottom);
  attribute each highlight pixel to exactly one tile by containment (nearest
  centre as tiebreak) so a border can't bleed into an adjacent tile.
- SignalAdapter: white border on, coloured off, name-at-bottom geometry.

Synthetic 4-tile harness now isolates each speaker with no adjacent-tile bleed;
all 15 XCTest cases pass. Real-screenshot geometry calibration still pending.
This commit is contained in:
Grant Gilliam
2026-06-06 09:52:10 -05:00
parent 863136aeec
commit a56b47143c
4 changed files with 116 additions and 46 deletions
@@ -34,10 +34,12 @@ final class GridCallAnalyzerTests: XCTestCase {
for (i, (name, rect)) in rects.enumerated() {
ctx.setFillColor(CGColor(red: 0.18, green: 0.18, blue: 0.2, alpha: 1)); ctx.fill(rect)
if i == speakingIndex {
ctx.setStrokeColor(CGColor(red: 0.1, green: 0.85, blue: 0.2, alpha: 1)); ctx.setLineWidth(14)
ctx.stroke(rect.insetBy(dx: 7, dy: 7))
// Signal's cue: a WHITE rounded border (not coloured).
ctx.setStrokeColor(CGColor(red: 1, green: 1, blue: 1, alpha: 1)); ctx.setLineWidth(6)
ctx.stroke(rect.insetBy(dx: 3, dy: 3))
}
drawText(name, ctx, center: CGPoint(x: rect.midX, y: rect.midY), size: 54)
// Name footer at the BOTTOM of the tile (bottom-left origin: rect.minY).
drawText(name, ctx, center: CGPoint(x: rect.midX, y: rect.minY + 28), size: 46)
}
return ctx.makeImage()!
}