Skip to content

Commit

Permalink
Merge pull request #1373 from danmana/feat/warn-apple-silicon-rosetta
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger committed Oct 6, 2022
2 parents 364c1b5 + 72f0756 commit 8c23211
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/docs/docs/troubleshooting/rosetta.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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();

1 comment on commit 8c23211

@vercel
Copy link

@vercel vercel bot commented on 8c23211 Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.