Skip to content

Commit

Permalink
Safari 14.1 support (#185)
Browse files Browse the repository at this point in the history
* Safari 14.1 fully supports Penumbra

* Default to 4 workers when `navigator.hardwareConcurrency` is not supported
  • Loading branch information
eligrey authored Apr 26, 2021
1 parent 3101b50 commit 688484b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@

## Compatibility

| | .decrypt | .encrypt | .saveZip |
| -------- | -------: | -------: | -------: |
| Chrome ||||
| Edge >18 ||||
| Safari | 🐢 | 🐢 | 🟡 |
| Firefox | 🐢 | 🐢 | 🟡 |
| Edge 18 ||||
| | .decrypt | .encrypt | .saveZip |
| ------------ | -------: | -------: | -------: |
| Chrome ||||
| Edge >18 ||||
| Safari ≥14.1 ||||
| Safari <14.1 | 🐢 | 🐢 | 🟡 |
| Firefox | 🐢 | 🐢 | 🟡 |
| Edge 18 ||||

✅ = Full support with workers

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@transcend-io/penumbra",
"version": "5.0.4",
"version": "5.0.5",
"description": "Crypto streams for the browser.",
"main": "build/main.penumbra.js",
"types": "ts-build/src/index.d.ts",
Expand Down
9 changes: 5 additions & 4 deletions src/workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ function reDispatchEvent(event: Event): void {

// Set data-worker-limit to limit the maximum number of Penumbra workers
const WORKER_LIMIT = +(script.workerLimit || 16);
const { hardwareConcurrency } = navigator;
// Get available processor threads
const availConcurrency = // Default to 4 threads if nav.hwConcurrency isn't supported
(navigator.hardwareConcurrency || 4) -
// Reserve one thread for UI renderer to prevent jank
1;
const availConcurrency = hardwareConcurrency
? // Reserve one thread (if hwConcurrency is supported) for UI renderer to prevent jank
hardwareConcurrency - 1
: 4;
const maxConcurrency =
availConcurrency > WORKER_LIMIT ? WORKER_LIMIT : availConcurrency;
const workers: PenumbraWorker[] = [];
Expand Down

0 comments on commit 688484b

Please sign in to comment.