Skip to content
Snippets Groups Projects
Unverified Commit 8ac7d00b authored by Jed Fox's avatar Jed Fox Committed by GitHub
Browse files

Allow bypassing SharedArrayBuffer override (#644)


* Allow bypassing SharedArrayBuffer override

* Make an attempt to avoid merging budgets

* Update FatalError.js

* s/allowBuggyFallback/isSharedArrayBufferOverrideEnabled/

Co-Authored-By: default avatarMatiss Janis Aboltins <886567+MatissJanis@users.noreply.github.com>

---------

Co-authored-by: default avatarMatiss Janis Aboltins <886567+MatissJanis@users.noreply.github.com>
parent e3bd9800
No related branches found
No related tags found
No related merge requests found
...@@ -18,11 +18,18 @@ function createBackendWorker() { ...@@ -18,11 +18,18 @@ function createBackendWorker() {
worker = new BackendWorker(); worker = new BackendWorker();
initSQLBackend(worker); initSQLBackend(worker);
if (window.SharedArrayBuffer) {
localStorage.removeItem('SharedArrayBufferOverride');
}
worker.postMessage({ worker.postMessage({
type: 'init', type: 'init',
version: ACTUAL_VERSION, version: ACTUAL_VERSION,
isDev: IS_DEV, isDev: IS_DEV,
hash: process.env.REACT_APP_BACKEND_WORKER_HASH hash: process.env.REACT_APP_BACKEND_WORKER_HASH,
isSharedArrayBufferOverrideEnabled: localStorage.getItem(
'SharedArrayBufferOverride'
)
}); });
if (IS_DEV || IS_PERF_BUILD) { if (IS_DEV || IS_PERF_BUILD) {
......
...@@ -10,7 +10,7 @@ self.addEventListener('message', e => { ...@@ -10,7 +10,7 @@ self.addEventListener('message', e => {
let version = msg.version; let version = msg.version;
let hash = msg.hash; let hash = msg.hash;
if (!self.SharedArrayBuffer) { if (!self.SharedArrayBuffer && !msg.isSharedArrayBufferOverrideEnabled) {
self.postMessage({ self.postMessage({
type: 'app-init-failure', type: 'app-init-failure',
SharedArrayBufferMissing: true SharedArrayBufferMissing: true
......
import React from 'react'; import React, { useState } from 'react';
import { import {
View, View,
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
Link, Link,
Button Button
} from 'loot-design/src/components/common'; } from 'loot-design/src/components/common';
import { Checkbox } from 'loot-design/src/components/forms';
import { colors } from 'loot-design/src/style'; import { colors } from 'loot-design/src/style';
class FatalError extends React.Component { class FatalError extends React.Component {
...@@ -38,7 +39,7 @@ class FatalError extends React.Component { ...@@ -38,7 +39,7 @@ class FatalError extends React.Component {
<a href="https://actualbudget.github.io/docs/Troubleshooting/SharedArrayBuffer"> <a href="https://actualbudget.github.io/docs/Troubleshooting/SharedArrayBuffer">
our troubleshooting documentation our troubleshooting documentation
</a>{' '} </a>{' '}
for more information. to learn more. <SharedArrayBufferOverride />
</Text> </Text>
); );
} else { } else {
...@@ -140,3 +141,52 @@ class FatalError extends React.Component { ...@@ -140,3 +141,52 @@ class FatalError extends React.Component {
} }
} }
export default FatalError; export default FatalError;
function SharedArrayBufferOverride() {
let [expanded, setExpanded] = useState(false);
let [understand, setUnderstand] = useState(false);
return expanded ? (
<>
<P style={{ marginTop: 10 }}>
Actual uses <code>SharedArrayBuffer</code> to allow usage from multiple
tabs at once and to ensure correct behavior when switching files. While
it can run without access to <code>SharedArrayBuffer</code>, you may
encounter data loss or notice multiple budget files being merged with
each other.
</P>
<label
style={{ display: 'flex', alignItems: 'center', marginBottom: 10 }}
>
<Checkbox checked={understand} onChange={setUnderstand} /> I understand
the risks, run Actual in the unsupported fallback mode
</label>
<Button
disabled={!understand}
onClick={() => {
window.localStorage.setItem('SharedArrayBufferOverride', 'true');
window.location.reload();
}}
>
Open Actual
</Button>
</>
) : (
<Link
onClick={() => setExpanded(true)}
style={{
color: `inherit !important`,
marginLeft: 5,
border: 'none !important',
background: 'none !important',
padding: '0 !important',
textDecoration: 'underline !important',
boxShadow: 'none !important',
display: 'inline !important',
font: 'inherit !important'
}}
>
Advanced options
</Link>
);
}
...@@ -119,6 +119,9 @@ export function closeBudget() { ...@@ -119,6 +119,9 @@ export function closeBudget() {
dispatch(setAppState({ loadingText: 'Closing...' })); dispatch(setAppState({ loadingText: 'Closing...' }));
await send('close-budget'); await send('close-budget');
dispatch(setAppState({ loadingText: null })); dispatch(setAppState({ loadingText: null }));
if (localStorage.getItem('SharedArrayBufferOverride')) {
location.reload();
}
} }
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment