remotion-dev/remotion · error · Error

Cannot change the behavior for pre-mounting audio tags dynam

Error message

Cannot change the behavior for pre-mounting audio tags dynamically.

What it means

Thrown by <Audio> in preview when the shouldPreMountAudioTags prop changes between renders. Remotion captures the initial premount decision on first render via useState and forbids changing it afterward, because switching premount strategy mid-lifecycle would desync audio tags.

Source

Thrown at packages/core/src/audio/AudioForPreview.tsx:49

type AudioForPreviewProps = RemotionAudioProps & {
	readonly shouldPreMountAudioTags: boolean;
	readonly onDuration: (src: string, durationInSeconds: number) => void;
	readonly pauseWhenBuffering: boolean;
	readonly _remotionInternalNativeLoopPassed: boolean;
	readonly _remotionInternalStack: string | null;
	readonly showInTimeline: boolean;
	readonly onNativeError: React.ReactEventHandler<HTMLAudioElement>;
};

const AudioForDevelopmentForwardRefFunction: React.ForwardRefRenderFunction<
	HTMLAudioElement,
	AudioForPreviewProps
> = (props, ref) => {
	const [initialShouldPreMountAudioElements] = useState(
		props.shouldPreMountAudioTags,
	);
	if (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {
		throw new Error(
			'Cannot change the behavior for pre-mounting audio tags dynamically.',
		);
	}

	const logLevel = useLogLevel();

	const {
		volume,
		muted,
		playbackRate,
		preservePitch,
		shouldPreMountAudioTags,
		src,
		onDuration,
		acceptableTimeShiftInSeconds,
		_remotionInternalNeedsDurationCalculation,
		_remotionInternalNativeLoopPassed,
		_remotionInternalStack,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Make shouldPreMountAudioTags stable across the component's lifetime (constant or fixed at mount).
  2. If you do not explicitly need this prop, omit it and let Remotion default it.
  3. Ensure the parent does not conditionally change the premount setting between renders.

Example fix

// before
<Audio src={src} shouldPreMountAudioTags={someCondition} />

// after
// omit the prop or make it stable:
<Audio src={src} />
Defensive patterns

Strategy: validation

Validate before calling

// Treat shouldPreMountAudioTags as constant for the component's lifetime.
const [premount] = useState(() => initialPremountValue);
// pass premount, never recompute it

Prevention

When it happens

Trigger: Passing shouldPreMountAudioTags that derives from mutable state, props, or context that changes after mount. This is normally an internal prop, so a change indicates an upstream conditional that flipped.

Common situations: Custom wrappers around <Audio> that compute shouldPreMountAudioTags from changing context; hot reload surfacing the mismatch; version mismatch where Remotion internals pass different values.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/ff3aac5088f6da68. Report an issue: GitHub.