Remove last use of Buffer in ringrtc API

Co-authored-by: Jim Gustafson <jim@signal.org>
This commit is contained in:
Miriam Zimmerman 2025-10-01 16:57:39 -04:00 committed by GitHub
commit dd1b7e6fc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 27 additions and 40 deletions

View file

@ -14517,7 +14517,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
```
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.58.1, protobuf 2.58.1, ringrtc 2.58.1, regex-aot 0.1.0, partial-default-derive 0.1.0
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.59.0, protobuf 2.59.0, ringrtc 2.59.0, regex-aot 0.1.0, partial-default-derive 0.1.0
```
GNU AFFERO GENERAL PUBLIC LICENSE

View file

@ -133,7 +133,7 @@
"@signalapp/libsignal-client": "0.81.1",
"@signalapp/minimask": "1.0.1",
"@signalapp/quill-cjs": "2.1.2",
"@signalapp/ringrtc": "2.58.1",
"@signalapp/ringrtc": "2.59.0",
"@signalapp/sqlcipher": "2.4.4",
"@signalapp/windows-ucv": "1.0.1",
"@tanstack/react-virtual": "3.11.2",

10
pnpm-lock.yaml generated
View file

@ -135,8 +135,8 @@ importers:
specifier: 2.1.2
version: 2.1.2
'@signalapp/ringrtc':
specifier: 2.58.1
version: 2.58.1
specifier: 2.59.0
version: 2.59.0
'@signalapp/sqlcipher':
specifier: 2.4.4
version: 2.4.4
@ -3471,8 +3471,8 @@ packages:
resolution: {integrity: sha512-y2sgqdivlrG41J4Zvt/82xtH/PZjDlgItqlD2g/Cv3ZbjlR6cGhTNXbfNygCJB8nXj+C7I28pjt1Zm3k0pv2mg==}
engines: {npm: '>=8.2.3'}
'@signalapp/ringrtc@2.58.1':
resolution: {integrity: sha512-u+80Vl460f4U4Btnv3blp2kbtPt29FHdC63mXaf1Yor5C/DH4xeb7HwYPdHW28cLu6xVBNw/j9h8DPJ0jrvbZw==}
'@signalapp/ringrtc@2.59.0':
resolution: {integrity: sha512-d0nim4iS7bkQuER7dZ1CgJePTJ4o9lb7ktm+DVTR7QZkq527dpeSwWOaywoiqo7V06KVp1D0vhby2PMxxLjyug==}
hasBin: true
'@signalapp/sqlcipher@2.4.4':
@ -14253,7 +14253,7 @@ snapshots:
lodash: 4.17.21
quill-delta: 5.1.0
'@signalapp/ringrtc@2.58.1':
'@signalapp/ringrtc@2.59.0':
dependencies:
https-proxy-agent: 7.0.6
tar: 6.2.1

View file

@ -307,7 +307,7 @@ export class GumVideoCapturer {
const reader = new MediaStreamTrackProcessor({
track,
}).readable.getReader();
const buffer = Buffer.alloc(MAX_VIDEO_CAPTURE_BUFFER_SIZE);
const buffer = new Uint8Array(MAX_VIDEO_CAPTURE_BUFFER_SIZE);
this.spawnedSenderRunning = true;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
@ -397,13 +397,13 @@ export const MAX_VIDEO_CAPTURE_BUFFER_SIZE = MAX_VIDEO_CAPTURE_AREA * 4;
export class CanvasVideoRenderer {
private canvas?: RefObject<HTMLCanvasElement>;
private buffer: Buffer;
private buffer: Uint8Array;
private imageData?: ImageData;
private source?: VideoFrameSource;
private rafId?: any;
constructor() {
this.buffer = Buffer.alloc(MAX_VIDEO_CAPTURE_BUFFER_SIZE);
this.buffer = new Uint8Array(MAX_VIDEO_CAPTURE_BUFFER_SIZE);
}
setCanvas(canvas: RefObject<HTMLCanvasElement> | undefined): void {

View file

@ -12,12 +12,12 @@ import { FRAME_BUFFER_SIZE } from './constants.js';
* of allocating one per participant. Be careful when using this buffer elsewhere, as it
* is not cleaned up and may hold stale data.
*/
export function useGetCallingFrameBuffer(): () => Buffer {
const ref = useRef<Buffer | null>(null);
export function useGetCallingFrameBuffer(): () => Uint8Array {
const ref = useRef<Uint8Array | null>(null);
return useCallback(() => {
if (!ref.current) {
ref.current = Buffer.alloc(FRAME_BUFFER_SIZE);
ref.current = new Uint8Array(FRAME_BUFFER_SIZE);
}
return ref.current;
}, []);

View file

@ -43,7 +43,7 @@ export default {
} satisfies Meta<PropsType>;
const defaultProps = {
getFrameBuffer: memoize(() => Buffer.alloc(FRAME_BUFFER_SIZE)),
getFrameBuffer: memoize(() => new Uint8Array(FRAME_BUFFER_SIZE)),
getCallingImageDataCache: memoize(() => new Map()),
getGroupCallVideoFrameSource: fakeGetGroupCallVideoFrameSource,
imageDataCache: React.createRef<CallingImageDataCache>(),

View file

@ -17,7 +17,7 @@ const OVERFLOW_SCROLL_BUTTON_RATIO = 0.75;
export const OVERFLOW_PARTICIPANT_WIDTH = 107;
export type PropsType = {
getFrameBuffer: () => Buffer;
getFrameBuffer: () => Uint8Array;
getGroupCallVideoFrameSource: (demuxId: number) => VideoFrameSource;
i18n: LocalizerType;
imageDataCache: React.RefObject<CallingImageDataCache>;

View file

@ -32,7 +32,7 @@ type OverridePropsType = {
}
);
const getFrameBuffer = memoize(() => Buffer.alloc(FRAME_BUFFER_SIZE));
const getFrameBuffer = memoize(() => new Uint8Array(FRAME_BUFFER_SIZE));
const createProps = (
overrideProps: OverridePropsType,

View file

@ -42,7 +42,7 @@ const DELAY_TO_SHOW_MISSING_MEDIA_KEYS = 5000;
const CONTAINER_TRANSITION_TIME = 200;
type BasePropsType = {
getFrameBuffer: () => Buffer;
getFrameBuffer: () => Uint8Array;
getGroupCallVideoFrameSource: (demuxId: number) => VideoFrameSource;
i18n: LocalizerType;
imageDataCache: React.RefObject<CallingImageDataCache>;

View file

@ -32,7 +32,7 @@ class FakeGroupCallVideoFrameSource implements VideoFrameSource {
}
receiveVideoFrame(
destinationBuffer: Buffer,
destinationBuffer: Uint8Array,
_maxWidth: number,
_maxHeight: number
): [number, number] | undefined {

View file

@ -65,7 +65,7 @@ describe('pnp/calling', function (this: Mocha.Suite) {
{
callMessage: {
offer: {
opaque: Buffer.alloc(1),
opaque: new Uint8Array(1),
},
},
},

View file

@ -44,7 +44,7 @@ describe('callingMessageToProto', () => {
it('attaches opaque data', () => {
const callingMessage = new CallingMessage();
callingMessage.opaque = new OpaqueMessage();
callingMessage.opaque.data = Buffer.from([1, 2, 3]);
callingMessage.opaque.data = new Uint8Array([1, 2, 3]);
const result = callingMessageToProto(callingMessage);
@ -74,7 +74,7 @@ describe('callingMessageToProto', () => {
it('attaches urgency and opaque data if both are provided', () => {
const callingMessage = new CallingMessage();
callingMessage.opaque = new OpaqueMessage();
callingMessage.opaque.data = Buffer.from([1, 2, 3]);
callingMessage.opaque.data = new Uint8Array([1, 2, 3]);
const result = callingMessageToProto(
callingMessage,

View file

@ -27,7 +27,7 @@ export function callingMessageToProto(
if (opaque) {
opaqueField = {
...opaque,
data: bufferToProto(opaque.data),
data: opaque.data,
};
}
if (urgency !== undefined) {
@ -43,14 +43,14 @@ export function callingMessageToProto(
...offer,
id: Long.fromValue(offer.callId),
type: offer.type as number,
opaque: bufferToProto(offer.opaque),
opaque: offer.opaque,
}
: undefined,
answer: answer
? {
...answer,
id: Long.fromValue(answer.callId),
opaque: bufferToProto(answer.opaque),
opaque: answer.opaque,
}
: undefined,
iceUpdate: iceCandidates
@ -58,7 +58,7 @@ export function callingMessageToProto(
return {
...candidate,
id: Long.fromValue(candidate.callId),
opaque: bufferToProto(candidate.opaque),
opaque: candidate.opaque,
};
})
: undefined,
@ -80,19 +80,6 @@ export function callingMessageToProto(
};
}
function bufferToProto(
value: Uint8Array | { toArrayBuffer(): ArrayBuffer } | undefined
): Uint8Array | undefined {
if (!value) {
return undefined;
}
if (value instanceof Uint8Array) {
return value;
}
return new Uint8Array(value.toArrayBuffer());
}
function urgencyToProto(
urgency: CallMessageUrgency
): Proto.CallMessage.Opaque.Urgency {

View file

@ -828,9 +828,9 @@
{
"rule": "React-useRef",
"path": "ts/calling/useGetCallingFrameBuffer.ts",
"line": " const ref = useRef<Buffer | null>(null);",
"line": " const ref = useRef<Uint8Array | null>(null);",
"reasonCategory": "usageTrusted",
"updated": "2021-12-10T23:24:03.829Z",
"updated": "2025-10-01T20:11:56Z",
"reasonDetail": "Doesn't touch the DOM."
},
{