Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warn apple silicon rosetta. Closes #1362 #1373

Merged
36 changes: 36 additions & 0 deletions packages/docs/docs/troubleshooting/rosetta.md
@@ -0,0 +1,36 @@
---
id: rosetta
sidebar_label: Rosetta
title: Apple Silicon under Rosetta
---

Running Remotion on Apple Silicon (M1 chip) under Rosetta can be up to 2x slower.

The recommended way to run Remotion on Apple Silicon is using Node 16 with the native arm64 architecture.

If you encounter the following warning while using `@remotion/renderer`:

```
Apple Silicon detected but running under Rosetta (not arm64 architecture). This will cause performance issues.
Recommended actions:
- Upgrade to Node 16.0.0 or later
- Run Node using `arch -arm64` architecture
```

You are either using Node 14 (which uses Rosetta on Apple M1 chips), or you are running a node version installed with `arch -x86_64`.

## Solution

1. Upgrade to Node 16 or later
1. Install Node and run it natively

For example, installing node natively using nvm:

```
arch -arm64 zsh
nvm install 16
```

You can check the architecture of your shell by typing in a terminal `arch`.
You can check the Node architecture by running in a terminal `node -p process.arch`.
If both of these print out `arm64` you are good to go.
1 change: 1 addition & 0 deletions packages/docs/sidebars.js
Expand Up @@ -346,6 +346,7 @@ module.exports = {
"wrong-composition-mount",
"staticfile-relative-paths",
"staticfile-remote-urls",
"troubleshooting/rosetta"
],
},

Expand Down
29 changes: 29 additions & 0 deletions packages/renderer/src/check-apple-silicon.ts
@@ -0,0 +1,29 @@
import * as os from 'os';

export const warnIfAppleSiliconIsNotUsingArm64Architecture = () => {
// see https://github.com/nodejs/node/issues/41900#issuecomment-1113511254
const cpus = os.cpus();
const isAppleSilicon = cpus[0].model.includes('Apple');
const isArm64 = os.arch() === 'arm64';

if (isAppleSilicon && !isArm64) {
const recommendedNodeVersion = 16;
const version = process.version.replace('v', '').split('.');
const majorVersion = Number(version[0]);
const recommendNodeUpgrade = majorVersion < recommendedNodeVersion;

console.warn(
[
`⚠️ Apple Silicon detected but Node.JS running under Rosetta. This will cause performance issues.\n`,
`Recommended actions:\n`,
recommendNodeUpgrade
? ` - Upgrade to Node ${recommendedNodeVersion} or later\n`
: ' - Run Node using `arch -arm64` architecture\n',
'See https://remotion.dev/docs/troubleshooting/rosetta for more information.',
'---',
]
.filter(Boolean)
.join('\n')
);
}
};
4 changes: 4 additions & 0 deletions packages/renderer/src/index.ts
Expand Up @@ -4,6 +4,7 @@ import {cleanDownloadMap, makeDownloadMap} from './assets/download-map';
import {DEFAULT_BROWSER} from './browser';
import {DEFAULT_TIMEOUT} from './browser/TimeoutSettings';
import {canUseParallelEncoding} from './can-use-parallel-encoding';
import {warnIfAppleSiliconIsNotUsingArm64Architecture} from './check-apple-silicon';
import {DEFAULT_CODEC, validCodecs} from './codec';
import {convertToPositiveFrameIndex} from './convert-to-positive-frame-index';
import {
Expand Down Expand Up @@ -168,3 +169,6 @@ export const RenderInternals = {
cleanDownloadMap,
convertToPositiveFrameIndex,
};

// Warn of potential performance issues with Apple Silicon (M1 chip under Rosetta)
warnIfAppleSiliconIsNotUsingArm64Architecture();