aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/reactions
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-04-24 17:01:25 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-05-16 00:55:02 +0200
commit0b632445a933644c7eb10015eb04b7c21d562900 (patch)
tree5bd1fe200cc747086220dbcba90097bfe2cc4cdc /packages/main/src/reactions
parentchore(deps): upgrade dependencies (diff)
downloadsophie-0b632445a933644c7eb10015eb04b7c21d562900.tar.gz
sophie-0b632445a933644c7eb10015eb04b7c21d562900.tar.zst
sophie-0b632445a933644c7eb10015eb04b7c21d562900.zip
refactor: reduce service switcher tearing
We render the location bar and notification banners separately for each service and keep track of the BrowserView size separately for each service to reduce the tearing that appears when people switch services. The tearing cannot be eliminated completely, because it comes from the separation between the main and renderer processes. But we can at least try and reduce the IPC round-tripping and layout calculations required to accurately position the services. This approach has an overhead compared to the single BrowserViewPlaceholder approach, because the renderer process has to layout the location bar and notification for all services, not only the selected one. The number of IPC messages during windows resize is also increased. To compensate, we increase the throttle interval for resize IPC messages and let electron itself resize the BrowserView between IPC updates. (We must still keep pumping IPC messages during window resize, because, e.g., changes in notification banner size due to re-layouting will still affect the required BrowserView size). If further reduction of IPC traffic is needed, we could implement batching for resize IPC messages and more intelligent throttling via a token bucker mechanism. Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/main/src/reactions')
-rw-r--r--packages/main/src/reactions/loadServices.ts8
1 files changed, 1 insertions, 7 deletions
diff --git a/packages/main/src/reactions/loadServices.ts b/packages/main/src/reactions/loadServices.ts
index 4ef6131..f56ac62 100644
--- a/packages/main/src/reactions/loadServices.ts
+++ b/packages/main/src/reactions/loadServices.ts
@@ -18,7 +18,7 @@
18 * SPDX-License-Identifier: AGPL-3.0-only 18 * SPDX-License-Identifier: AGPL-3.0-only
19 */ 19 */
20 20
21import { autorun, reaction } from 'mobx'; 21import { reaction } from 'mobx';
22import { addDisposer } from 'mobx-state-tree'; 22import { addDisposer } from 'mobx-state-tree';
23 23
24import type { 24import type {
@@ -94,7 +94,6 @@ export default function loadServices(
94 throw new Error(`Missing Partition ${profileId}`); 94 throw new Error(`Missing Partition ${profileId}`);
95 } 95 }
96 view = viewFactory.createServiceView(service, partition); 96 view = viewFactory.createServiceView(service, partition);
97 view.setBounds(store.browserViewBounds);
98 servicesToViews.set(serviceId, view); 97 servicesToViews.set(serviceId, view);
99 service.setServiceView(view); 98 service.setServiceView(view);
100 const { urlToLoad } = service; 99 const { urlToLoad } = service;
@@ -133,12 +132,7 @@ export default function loadServices(
133 }, 132 },
134 ); 133 );
135 134
136 const resizeDisposer = autorun(() => {
137 store.visibleService?.serviceView?.setBounds(store.browserViewBounds);
138 });
139
140 addDisposer(store, () => { 135 addDisposer(store, () => {
141 resizeDisposer();
142 disposer(); 136 disposer();
143 store.mainWindow?.setServiceView(undefined); 137 store.mainWindow?.setServiceView(undefined);
144 servicesToViews.forEach((serviceView, serviceId) => { 138 servicesToViews.forEach((serviceView, serviceId) => {