π₯ Make videos programmatically with React
remove errorBehavior prop
Igor Samokhovets1d8809ed488c
diff --git a/packages/core/src/Img.tsx b/packages/core/src/Img.tsxindex 28cdd5d4a2..632d9ead32 100644--- a/packages/core/src/Img.tsx+++ b/packages/core/src/Img.tsx@@ -34,18 +34,9 @@ export type ImgProps = NativeImgProps & {readonly delayRenderTimeoutInMilliseconds?: number;readonly onImageFrame?: (imageElement: HTMLImageElement) => void;readonly src: string;- /**- * @description Controls what happens when the image fails to load or cannot be drawn to canvas (e.g., due to CORS restrictions).- * @default 'fail'- * @see [Documentation](https://remotion.dev/docs/img)- */- readonly errorBehavior?: 'fail' | 'ignore';};-type Expected = Omit<- NativeImgProps,- 'onError' | 'src' | 'crossOrigin' | 'errorBehavior'->;+type Expected = Omit<NativeImgProps, 'onError' | 'src' | 'crossOrigin'>;const ImgRefForwarding: React.ForwardRefRenderFunction<HTMLImageElement,@@ -60,7 +51,6 @@ const ImgRefForwarding: React.ForwardRefRenderFunction<delayRenderTimeoutInMilliseconds,onImageFrame,crossOrigin,- errorBehavior,...props},ref,@@ -264,9 +254,6 @@ const ImgRefForwarding: React.ForwardRefRenderFunction<crossOrigin={crossOriginValue}onError={didGetError}decoding="sync"- data-remotion-error-behavior={- errorBehavior === 'ignore' ? 'ignore' : undefined- }/>);};diff --git a/packages/docs/docs/client-side-rendering/migration.mdx b/packages/docs/docs/client-side-rendering/migration.mdxindex 0310a992d5..30e5024650 100644--- a/packages/docs/docs/client-side-rendering/migration.mdx+++ b/packages/docs/docs/client-side-rendering/migration.mdx@@ -61,14 +61,6 @@ This usually means the image failed to load - check that the URL is valid and ac3. **Use a CORS proxy**: Route requests through a proxy that adds CORS headers.-4. **Use `errorBehavior="ignore"`**: If you want to gracefully skip images that fail to load or are tainted, use the [`errorBehavior`](/docs/img#errorbehavior) prop on `<Img>`:--```tsx-<Img src="https://example.com/maybe-cors-enabled.png" errorBehavior="ignore" />-```--This will render nothing instead of failing the render if the image cannot be drawn to canvas.-## Use `@remotion/media`The only video and audio tags that are supported are [`<Video>`](/docs/media/video) and [`<Audio>`](/docs/media/audio) from `@remotion/media`.diff --git a/packages/docs/docs/img.mdx b/packages/docs/docs/img.mdxindex 503225bb21..f4dcd9af6c 100644--- a/packages/docs/docs/img.mdx+++ b/packages/docs/docs/img.mdx@@ -86,34 +86,6 @@ Customize the [timeout](/docs/delay-render#modifying-the-timeout) of the [`delayCustomize the [number of retries](/docs/delay-render#retrying) of the [`delayRender()`](/docs/delay-render) call that this component makes.Prefer the [`maxRetries`](#maxretries) prop over this.-### `errorBehavior`<AvailableFrom v="4.0.398" />--_optional_--Controls what happens when the image cannot be drawn to the canvas during [client-side rendering](/docs/client-side-rendering). This can happen when:--- The image fails to load (404, network error, invalid URL)-- The image is tainted due to CORS restrictions--**Values:**--- `"fail"` (default): The render will fail with an error message explaining the problem.-- `"ignore"`: The image will be skipped and nothing will be rendered in its place.--```tsx twoslash-import {AbsoluteFill, Img} from 'remotion';--export const MyComp: React.FC = () => {- return (- <AbsoluteFill>- <Img src="https://example.com/maybe-cors-enabled.png" errorBehavior="ignore" />- </AbsoluteFill>- );-};-```--This prop is primarily useful for client-side rendering where CORS restrictions are enforced. See [Migrating to client-side rendering](/docs/client-side-rendering/migration#ensure-assets-are-available-via-cors) for more information.-## Other propsRemotion inherits the props of the regular `<img>` tag, like for example `style`.diff --git a/packages/web-renderer/src/drawing/draw-dom-element.ts b/packages/web-renderer/src/drawing/draw-dom-element.tsindex 0c94f26b55..044dd391fe 100644--- a/packages/web-renderer/src/drawing/draw-dom-element.ts+++ b/packages/web-renderer/src/drawing/draw-dom-element.ts@@ -52,14 +52,6 @@ export const drawDomElement = (node: HTMLElement | SVGElement) => {dimensions.height,);} catch (err) {- // Check if we should ignore errors for this element- if (- node instanceof HTMLImageElement &&- node.dataset.remotionErrorBehavior === 'ignore'- ) {- return;- }-// Provide readable error messages for image errorsif (node instanceof HTMLImageElement) {const readableError = getReadableImageError(err, node);diff --git a/packages/web-renderer/src/test/tainted-image.test.tsx b/packages/web-renderer/src/test/tainted-image.test.tsxindex 9dee209c3c..a71532f31f 100644--- a/packages/web-renderer/src/test/tainted-image.test.tsx+++ b/packages/web-renderer/src/test/tainted-image.test.tsx@@ -1,14 +1,14 @@import {AbsoluteFill, Img} from 'remotion';import {expect, test} from 'vitest';import {renderStillOnWeb} from '../render-still-on-web';-import {testImage} from './utils';-// Note: The behavior of tainted images varies by browser:+// Note: The behavior varies by browser when loading an image that redirects+// without CORS headers (like https://github.com/JonnyBurger.png):// - Chromium/Firefox: Image fails to load when crossOrigin="anonymous" is set-// and server doesn't support CORS β "broken state" error-// - WebKit: Image may load as tainted but still render in some cases-// This test verifies we get a readable error message in either case.-test('should throw readable error for tainted or broken image', async (t) => {+// and the redirect response doesn't have CORS headers β "broken state" error+// - WebKit: May handle the redirect differently and succeed in some cases+// This test verifies we get a readable error message for CORS-related failures.+test('should throw readable error for image that fails to load due to CORS', async (t) => {const Component: React.FC = () => {return (<AbsoluteFill>@@ -51,31 +51,3 @@ test('should throw readable error for tainted or broken image', async (t) => {expect(hasReadableError).toBe(true);}});--test('should render nothing when errorBehavior="ignore" for tainted image', async () => {- const Component: React.FC = () => {- return (- <AbsoluteFill style={{backgroundColor: 'red'}}>- <Img src="https://github.com/JonnyBurger.png" errorBehavior="ignore" />- </AbsoluteFill>- );- };-- // Should not throw, should render just the red background- const {blob} = await renderStillOnWeb({- licenseKey: 'free-license',- composition: {- component: Component,- id: 'ignore-error-test',- width: 100,- height: 100,- fps: 30,- durationInFrames: 1,- },- frame: 0,- inputProps: {},- imageFormat: 'png',- });-- await testImage({blob, testId: 'tainted-image-ignored'});-});