Skip to content

🎥 Make videos programmatically with React

remotion: Fix Series sequence stack traces

Jonny Burger30a6d53f9971
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsx
index c6d56d1f8f..f14c1c8041 100644
--- a/packages/core/src/Sequence.tsx
+++ b/packages/core/src/Sequence.tsx
@@ -75,7 +75,7 @@ export type SequencePropsWithoutDuration = {
/**
* @deprecated For internal use only.
*/
- readonly _remotionInternalStack?: string;
+ readonly _remotionInternalStack?: string | null;
/**
* @deprecated For internal use only.
*/
@@ -278,11 +278,11 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
const isInsideSeries = useContext(IsInsideSeriesContext);
- const inheritedStack = (other as any)?.stack ?? null;
+ const inheritedStack = (other as {readonly stack?: string})?.stack ?? null;
// Our assumption: Stack doesnt' change. After we symbolicate we assign it a nodePath
// and if it changes, it would lead to-remounting of the sequence.
const stackRef = useRef<string | null>(null);
- stackRef.current = stack ?? inheritedStack;
+ stackRef.current = stack === undefined ? inheritedStack : stack;
useEffect(() => {
if (!env.isStudio) {
diff --git a/packages/core/src/series/index.tsx b/packages/core/src/series/index.tsx
index b21c042614..1dcb2c7f50 100644
--- a/packages/core/src/series/index.tsx
+++ b/packages/core/src/series/index.tsx
@@ -23,6 +23,10 @@ type SeriesSequenceProps = PropsWithChildren<
readonly durationInFrames: number;
readonly offset?: number;
readonly className?: string;
+ /**
+ * @deprecated For internal use only.
+ */
+ readonly stack?: string;
} & Pick<SequenceProps, 'layout' | 'name' | 'hidden'> &
LayoutAndStyle
>;
@@ -115,6 +119,7 @@ const SeriesInner: FC<SeriesProps> = (props) => {
const currentStartFrame = startFrame + offset;
startFrame += durationInFramesProp + offset;
+ const sequenceStack = passedProps.stack ?? null;
return (
<SequenceWithoutFromWithRef
@@ -126,12 +131,14 @@ const SeriesInner: FC<SeriesProps> = (props) => {
from={currentStartFrame}
durationInFrames={durationInFramesProp}
{...passedProps}
+ _remotionInternalStack={sequenceStack}
>
{child}
</SequenceWithoutFromWithRef>
);
});
}, [props.children]);
+ const seriesStack = (props as {readonly stack?: string}).stack ?? null;
return (
<IsInsideSeriesContainer>
@@ -140,6 +147,7 @@ const SeriesInner: FC<SeriesProps> = (props) => {
name="<Series>"
_remotionInternalDocumentationLink="https://www.remotion.dev/docs/series"
{...props}
+ _remotionInternalStack={seriesStack}
>
{childrenValue}
</Sequence>
diff --git a/packages/core/src/test/sequence-register-once.test.tsx b/packages/core/src/test/sequence-register-once.test.tsx
index 42ef7f7d29..479ed4d79e 100644
--- a/packages/core/src/test/sequence-register-once.test.tsx
+++ b/packages/core/src/test/sequence-register-once.test.tsx
@@ -164,6 +164,58 @@ test('Series.Sequence registers controls without a from field', () => {
}
});
+test('Sequence can ignore internally injected stack traces', () => {
+ const registeredSequences: TSequence[] = [];
+ const SequenceWithStack = Sequence as React.ComponentType<
+ React.ComponentProps<typeof Sequence> & {readonly stack?: string}
+ >;
+
+ render(
+ <SequenceTestWrapper
+ onRegisterSequence={(sequence) => {
+ registeredSequences.push(sequence);
+ }}
+ >
+ <SequenceWithStack stack="core-stack" _remotionInternalStack={null}>
+ hi
+ </SequenceWithStack>
+ </SequenceTestWrapper>,
+ );
+
+ expect(registeredSequences[0]?.getStack()).toBe(null);
+});
+
+test('Series forwards userland stack traces to its internal sequences', () => {
+ const registeredSequences: TSequence[] = [];
+ const seriesSequenceProps = {
+ durationInFrames: 10,
+ premountFor: 30,
+ stack: 'sequence-userland-stack',
+ } as React.ComponentProps<typeof Series.Sequence> & {readonly stack: string};
+
+ render(
+ <SequenceTestWrapper
+ onRegisterSequence={(sequence) => {
+ registeredSequences.push(sequence);
+ }}
+ >
+ <Series {...({stack: 'series-userland-stack'} as {stack: string})}>
+ <Series.Sequence {...seriesSequenceProps}>First</Series.Sequence>
+ </Series>
+ </SequenceTestWrapper>,
+ );
+
+ const series = registeredSequences.find(
+ (sequence) => sequence.displayName === '<Series>',
+ );
+ const seriesSequence = registeredSequences.find(
+ (sequence) => sequence.displayName === '<Series.Sequence>',
+ );
+
+ expect(series?.getStack()).toBe('series-userland-stack');
+ expect(seriesSequence?.getStack()).toBe('sequence-userland-stack');
+});
+
test('Img registers its documentation link for default labels', () => {
const registeredSequences: TSequence[] = [];
diff --git a/packages/transitions/src/TransitionSeries.tsx b/packages/transitions/src/TransitionSeries.tsx
index a7fbaf8f55..8b73749812 100644
--- a/packages/transitions/src/TransitionSeries.tsx
+++ b/packages/transitions/src/TransitionSeries.tsx
@@ -469,6 +469,7 @@ const TransitionSeriesChildren: FC<{readonly children: React.ReactNode}> = ({
from={actualStartFrame}
durationInFrames={durationInFramesProp}
{...passedProps}
+ _remotionInternalStack={passedProps.stack ?? null}
name={passedProps.name || '<TS.Sequence>'}
_remotionInternalDocumentationLink={
passedProps.name
@@ -533,6 +534,7 @@ const TransitionSeriesChildren: FC<{readonly children: React.ReactNode}> = ({
from={actualStartFrame}
durationInFrames={durationInFramesProp}
{...passedProps}
+ _remotionInternalStack={passedProps.stack ?? null}
name={passedProps.name || '<TS.Sequence>'}
_remotionInternalDocumentationLink={
passedProps.name
@@ -577,6 +579,7 @@ const TransitionSeriesChildren: FC<{readonly children: React.ReactNode}> = ({
from={actualStartFrame}
durationInFrames={durationInFramesProp}
{...passedProps}
+ _remotionInternalStack={passedProps.stack ?? null}
name={passedProps.name || '<TS.Sequence>'}
_remotionInternalDocumentationLink={
passedProps.name
@@ -614,6 +617,7 @@ const TransitionSeriesChildren: FC<{readonly children: React.ReactNode}> = ({
from={actualStartFrame}
durationInFrames={durationInFramesProp}
{...passedProps}
+ _remotionInternalStack={passedProps.stack ?? null}
name={passedProps.name || '<TS.Sequence>'}
_remotionInternalDocumentationLink={
passedProps.name
@@ -646,6 +650,7 @@ const TransitionSeriesChildren: FC<{readonly children: React.ReactNode}> = ({
_remotionInternalDocumentationLink="https://www.remotion.dev/docs/transitions/transitionseries"
layout="absolute-fill"
{...(info.stack ? {stack: info.stack} : {})}
+ _remotionInternalStack={info.stack ?? null}
>
{info.children}
</Sequence>
@@ -689,6 +694,9 @@ const TransitionSeries: FC<SequencePropsWithoutDuration> & {
: undefined
}
{...otherProps}
+ _remotionInternalStack={
+ (otherProps as {readonly stack?: string}).stack ?? null
+ }
>
<TransitionSeriesChildren>{children}</TransitionSeriesChildren>
</Sequence>