From 6735945b83105818d9eddaa9bc691655849eee9d Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 20 Mar 2024 20:31:04 +0100 Subject: [PATCH 01/14] Refactor: avoid reading from persisted store on each render --- src/components/SaveExport/ExportDialog.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/SaveExport/ExportDialog.tsx b/src/components/SaveExport/ExportDialog.tsx index f784d8a4..0ba16e2f 100644 --- a/src/components/SaveExport/ExportDialog.tsx +++ b/src/components/SaveExport/ExportDialog.tsx @@ -4,7 +4,13 @@ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause */ -import React, { useEffect, useMemo, useRef, useState } from 'react'; +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; import ProgressBar from 'react-bootstrap/ProgressBar'; import { useDispatch, useSelector } from 'react-redux'; import { dialog, getCurrentWindow } from '@electron/remote'; @@ -149,12 +155,14 @@ export default () => { .replace('u', '\u00B5') ); }, [duration]); - const filename = createFileName(); - const close = () => { + + const close = useCallback(() => { cancel.current = true; dispatch(hideExportDialog()); - }; + }, [dispatch]); + const saveFile = async () => { + const filename = createFileName(); const { filePath: fn } = await dialog.showSaveDialog( getCurrentWindow(), { From 9ac25d16f2420247a06968c4c586131f30b5ddac Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 20 Mar 2024 20:31:46 +0100 Subject: [PATCH 02/14] Feat: performance on retina displays --- src/components/Chart/AmpereChart.tsx | 1 + src/features/minimap/Minimap.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/Chart/AmpereChart.tsx b/src/components/Chart/AmpereChart.tsx index abb31aef..bba1bcd4 100644 --- a/src/components/Chart/AmpereChart.tsx +++ b/src/components/Chart/AmpereChart.tsx @@ -244,6 +244,7 @@ export default ({ }, }, }, + devicePixelRatio: 1, parsing: false, maintainAspectRatio: false, animation: false, diff --git a/src/features/minimap/Minimap.tsx b/src/features/minimap/Minimap.tsx index 94883f2c..18b87fda 100644 --- a/src/features/minimap/Minimap.tsx +++ b/src/features/minimap/Minimap.tsx @@ -332,6 +332,7 @@ function initializeMinimapChart( ], }, options: { + devicePixelRatio: 1, animation: false, layout: { autoPadding: false, From 7e459ed10dabdfc46fe860f081633415b4139d94 Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 20 Mar 2024 20:32:25 +0100 Subject: [PATCH 03/14] Feat: disable parsing flag --- src/features/minimap/Minimap.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/features/minimap/Minimap.tsx b/src/features/minimap/Minimap.tsx index 18b87fda..dc618659 100644 --- a/src/features/minimap/Minimap.tsx +++ b/src/features/minimap/Minimap.tsx @@ -332,6 +332,7 @@ function initializeMinimapChart( ], }, options: { + parsing: false, devicePixelRatio: 1, animation: false, layout: { From 7469e0d5e214287451ddeb944313f4f8897c5d66 Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 20 Mar 2024 20:38:46 +0100 Subject: [PATCH 04/14] Feat: version and changelog --- Changelog.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 55ca7cac..1070ed88 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ +## 4.0.1 - UNRELEASED + +### Fixed + +- Performance improvements for Retina Displays. + ## 4.0.0 - 2024-03-13 ### Added diff --git a/package.json b/package.json index 6b20ce8a..d12f9057 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pc-nrfconnect-ppk", - "version": "4.0.0", + "version": "4.0.1", "displayName": "Power Profiler", "description": "App for use with Nordic Power Profiler Kits", "homepage": "https://github.com/NordicSemiconductor/pc-nrfconnect-ppk", From 6a47f008b455140744f35f2ff8d130b550a075ad Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 20 Mar 2024 21:11:19 +0100 Subject: [PATCH 05/14] Feat: Update chart js --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index d693c9df..375021fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pc-nrfconnect-ppk", - "version": "4.0.0", + "version": "4.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pc-nrfconnect-ppk", - "version": "4.0.0", + "version": "4.0.1", "bundleDependencies": [ "archiver" ], @@ -21,7 +21,7 @@ "@types/redux-mock-store": "^1.0.3", "@types/unzipper": "^0.10.9", "bson": "4.6.5", - "chart.js": "^4.3.3", + "chart.js": "^4.4.2", "mathjs": "^10.6.3", "react-chartjs-2": "^5.2.0", "redux-mock-store": "^1.5.4", @@ -6108,15 +6108,15 @@ "dev": true }, "node_modules/chart.js": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.3.3.tgz", - "integrity": "sha512-aTk7pBw+x6sQYhon/NR3ikfUJuym/LdgpTlgZRe2PaEhjUMKBKyNaFCMVRAyTEWYFNO7qRu7iQVqOw/OqzxZxQ==", + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.2.tgz", + "integrity": "sha512-6GD7iKwFpP5kbSD4MeRRRlTnQvxfQREy36uEtm1hzHzcOqwWx0YEHuspuoNlslu+nciLIB7fjjsHkUv/FzFcOg==", "dev": true, "dependencies": { "@kurkle/color": "^0.3.0" }, "engines": { - "pnpm": ">=7" + "pnpm": ">=8" } }, "node_modules/chokidar": { diff --git a/package.json b/package.json index d12f9057..4f42805b 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@types/redux-mock-store": "^1.0.3", "@types/unzipper": "^0.10.9", "bson": "4.6.5", - "chart.js": "^4.3.3", + "chart.js": "^4.4.2", "mathjs": "^10.6.3", "react-chartjs-2": "^5.2.0", "redux-mock-store": "^1.5.4", From 0561b77c89b460bc0f3fd1d09f2e4e9257d6a8cc Mon Sep 17 00:00:00 2001 From: Sviatoslav Svitlychnyi Date: Tue, 26 Mar 2024 16:06:34 +0100 Subject: [PATCH 06/14] Update Changelog.md Co-authored-by: Grzegorz Ferenc <41291385+greg-fer@users.noreply.github.com> --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 1070ed88..f701a812 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,7 @@ ### Fixed -- Performance improvements for Retina Displays. +- Performance improvements for Retina displays. ## 4.0.0 - 2024-03-13 From 12e9be10c478aadb36b88369c3be2a1fa89eed9c Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 16:11:58 +0100 Subject: [PATCH 07/14] Feat: avoid creating new view per add --- src/globals.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/globals.ts b/src/globals.ts index 85bcdb25..79a7969d 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -23,6 +23,8 @@ const initialSamplesPerSecond = 1e6 / initialSamplingTime; export const microSecondsPerSecond = 1e6; const tempBuffer = new Uint8Array(6); +const tempView = new DataView(tempBuffer.buffer); + export interface GlobalOptions { /** The number of samples per second */ samplesPerSecond: number; @@ -199,9 +201,8 @@ export const DataManager = () => ({ ) return; - const view = new DataView(tempBuffer.buffer); - view.setFloat32(0, current, true); - view.setUint16(4, bits); + tempView.setFloat32(0, current, true); + tempView.setUint16(4, bits); if (options.writeBuffer) { options.writeBuffer.append(tempBuffer); From 02de262548ac2a9f76f6953e19b869ce41461eeb Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 16:16:14 +0100 Subject: [PATCH 08/14] Feat: avoid dispathing when out of synck --- src/actions/deviceActions.ts | 9 +++++++-- src/components/Chart/Chart.tsx | 8 -------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/actions/deviceActions.ts b/src/actions/deviceActions.ts index a85807bd..d4561e1d 100644 --- a/src/actions/deviceActions.ts +++ b/src/actions/deviceActions.ts @@ -393,13 +393,18 @@ export const open = clearInterval(updateRequestInterval); let renderIndex: number; + let lastRenderRequestTime = 0; updateRequestInterval = setInterval(() => { + const now = Date.now(); if ( renderIndex !== DataManager().getTotalSavedRecords() && getState().app.app.samplingRunning && - isDataLoggerPane(getState()) + isDataLoggerPane(getState()) && + (DataManager().isInSync() || + now - lastRenderRequestTime >= 1000) // force 1 FPS ) { - const timestamp = Date.now(); + const timestamp = now; + lastRenderRequestTime = now; if (getState().app.chart.liveMode) { requestAnimationFrame(() => { /* diff --git a/src/components/Chart/Chart.tsx b/src/components/Chart/Chart.tsx index 991bcffb..0ea93b8f 100644 --- a/src/components/Chart/Chart.tsx +++ b/src/components/Chart/Chart.tsx @@ -471,20 +471,12 @@ const Chart = () => { } }, [xAxisMax]); - const lastLiveRenderTime = useRef(0); const lastFPSUpdate = useRef(performance.now()); const fpsCounter = useRef(0); useEffect(() => { const now = performance.now(); - const forceRender = now - lastLiveRenderTime.current > 1000; // force 1 FPS if (liveMode) { - if (!DataManager().isInSync() && !forceRender) { - return; - } - - lastLiveRenderTime.current = now; - nextUpdateRequests = () => { fpsCounter.current += 1; return updateChart( From 884d9def3594575e4a0fe34255a1fedc58dc04ed Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 16:17:11 +0100 Subject: [PATCH 09/14] Feat: Adapt to sampling rate for update --- src/actions/deviceActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/deviceActions.ts b/src/actions/deviceActions.ts index d4561e1d..999efa18 100644 --- a/src/actions/deviceActions.ts +++ b/src/actions/deviceActions.ts @@ -428,7 +428,7 @@ export const open = }); renderIndex = DataManager().getTotalSavedRecords(); } - }, 30); + }, Math.max(30, DataManager().getSamplingTime() / 1000)); }; export const updateRegulator = From bfd4b3ac82753948ae819cacc3390b90f8796ec1 Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 16:20:49 +0100 Subject: [PATCH 10/14] Feat: Redefined not in sync --- src/globals.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/globals.ts b/src/globals.ts index 79a7969d..3faab867 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -184,13 +184,10 @@ export const DataManager = () => ({ if (simulationDelta > actualTimePassed) return true; const pcAheadDelta = actualTimePassed - simulationDelta; - if ( - pcAheadDelta > - Math.max(30, getSamplingTime(options.samplesPerSecond) * 1.5) - ) { - return false; - } - return true; + + // We get serial data every 30 ms regardless of sampling rate. + // If PC is ahead by more then 1.5 samples we are not in sync + return pcAheadDelta <= 45; }, getStartSystemTime: () => options.fileBuffer?.getFirstWriteTime(), From 14ddab0384ac424271fbca6f164d7586ef123a4f Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 17:03:56 +0100 Subject: [PATCH 11/14] Fix: frame trotteling on slower machines --- src/globals.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals.ts b/src/globals.ts index 3faab867..e79b337f 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -176,7 +176,7 @@ export const DataManager = () => ({ getTimestamp, isInSync: () => { const actualTimePassed = - performance.now() - + Date.now() - (options.writeBuffer?.getFirstWriteTime() ?? options.fileBuffer?.getFirstWriteTime() ?? 0); From 7b184da0246039650ee26fef00cd6754f82029b4 Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 17:05:37 +0100 Subject: [PATCH 12/14] Revert retina pixel ration changes --- src/components/Chart/AmpereChart.tsx | 1 - src/features/minimap/Minimap.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/Chart/AmpereChart.tsx b/src/components/Chart/AmpereChart.tsx index bba1bcd4..abb31aef 100644 --- a/src/components/Chart/AmpereChart.tsx +++ b/src/components/Chart/AmpereChart.tsx @@ -244,7 +244,6 @@ export default ({ }, }, }, - devicePixelRatio: 1, parsing: false, maintainAspectRatio: false, animation: false, diff --git a/src/features/minimap/Minimap.tsx b/src/features/minimap/Minimap.tsx index dc618659..14e8fdc6 100644 --- a/src/features/minimap/Minimap.tsx +++ b/src/features/minimap/Minimap.tsx @@ -333,7 +333,6 @@ function initializeMinimapChart( }, options: { parsing: false, - devicePixelRatio: 1, animation: false, layout: { autoPadding: false, From 73959249a01f7288b354380e9b486c3dd31ceb69 Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 17:05:52 +0100 Subject: [PATCH 13/14] Feat: Update changelog --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index f701a812..8e7ea8a6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,7 @@ ### Fixed -- Performance improvements for Retina displays. +- Chart frame trotting for slower machines ## 4.0.0 - 2024-03-13 From 0dab407bd383977357a48c16bc03a0523d408500 Mon Sep 17 00:00:00 2001 From: kylebonnici Date: Wed, 27 Mar 2024 17:13:00 +0100 Subject: [PATCH 14/14] Feat: update shared --- Changelog.md | 5 +++++ package-lock.json | 8 ++++---- package.json | 2 +- src/index.tsx | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 8e7ea8a6..9d341953 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ ## 4.0.1 - UNRELEASED +### Changed + +- Moved feedback tab to a dialog which can be opened by going to the about tab + and click **Give Feedback** + ### Fixed - Chart frame trotting for slower machines diff --git a/package-lock.json b/package-lock.json index 375021fe..0e434a42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "archiver": "^6.0.1" }, "devDependencies": { - "@nordicsemiconductor/pc-nrfconnect-shared": "^167.0.0", + "@nordicsemiconductor/pc-nrfconnect-shared": "^170.0.0", "@types/archiver": "^6.0.2", "@types/fs-extra": "^11.0.4", "@types/redux-mock-store": "^1.0.3", @@ -2889,9 +2889,9 @@ } }, "node_modules/@nordicsemiconductor/pc-nrfconnect-shared": { - "version": "167.0.0", - "resolved": "https://registry.npmjs.org/@nordicsemiconductor/pc-nrfconnect-shared/-/pc-nrfconnect-shared-167.0.0.tgz", - "integrity": "sha512-UHu7sokZu/HRhz1CemSas6Lkv1YQWxIhahkt8eVzJ7DfAFaUrfjzqg5bXDi0NzXYi5geGeJrL1gYgVetxrBIiA==", + "version": "170.0.0", + "resolved": "https://registry.npmjs.org/@nordicsemiconductor/pc-nrfconnect-shared/-/pc-nrfconnect-shared-170.0.0.tgz", + "integrity": "sha512-mZMPYpJRkqjwb74ueA2cHsR8HZVRboXeIvqfL8aScBUKRyC1aMEeV8JPCwxRVvM4FArWKUz9WOgWxuJtGNUUTA==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/package.json b/package.json index 4f42805b..64858a48 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "nordic-publish": "node ./dist/nordic-publish.js" }, "devDependencies": { - "@nordicsemiconductor/pc-nrfconnect-shared": "^167.0.0", + "@nordicsemiconductor/pc-nrfconnect-shared": "^170.0.0", "@types/archiver": "^6.0.2", "@types/fs-extra": "^11.0.4", "@types/redux-mock-store": "^1.0.3", diff --git a/src/index.tsx b/src/index.tsx index 257a005c..6f8dd50c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -81,7 +81,6 @@ render( appReducer={reducers} deviceSelect={} sidePanel={} - feedback documentation={DocumentationSections} panes={[ { name: 'Data Logger', Main: ChartWrapper },