Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory visualization #321

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Add memory visualization #321

wants to merge 7 commits into from

Conversation

jesper2k
Copy link

@jesper2k jesper2k commented Aug 25, 2022

Code is copied from this repo, with a few manual changes, mostly just renaming from "memory-visualization" to "programmer" and a few dependencies for reading elf-files.

@jesper2k
Copy link
Author

I see that some of the errors come from using a value that doesn't exist yet, which often boils down to finding the width or height of some component before it's rendered. This has lead to a few "1 frame latency" problems:

  • If the tooltip changes position from top to bottom, it's direction is one frame too late
  • When the scrollbar appears, it will cover underlying elements until the next render

Is there some way to render the elements twice and use their first width for the second render to avoid this problem? It gives an error in the editor, but not even a warning in the dev console when running in the app.

@jesper2k jesper2k removed the request for review from boundlesscalm August 30, 2022 07:00
src/actions/fileActions.ts Outdated Show resolved Hide resolved
src/actions/fileActions.ts Outdated Show resolved Hide resolved
src/actions/jlinkTargetActions.ts Outdated Show resolved Hide resolved
src/components/AppMainView.tsx Outdated Show resolved Hide resolved
iconName="mdi mdi-folder-open"
title="Memory visualization"
description="Drag & drop HEX/ZIP/ELF files here"
iconName="mdi mdi-file-outline"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for changing the title and icon?

Copy link
Author

Choose a reason for hiding this comment

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

I would think it's more intuitive that you're looking at an elf-file if there's a file icon + extension, than if you just see a directory/folder icon. But the title change should be reverted, thanks for catching that.

Copy link
Contributor

Choose a reason for hiding this comment

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

As it is right now it changes the default behaviour so that mdi-file-outline is shown also for all other states (like no files or other file types).
Do ask Ketil though, maybe he thinks this is how it should be.

Copy link
Author

Choose a reason for hiding this comment

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

image
Ketil approves

Copy link
Contributor

Choose a reason for hiding this comment

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

1337

Copy link
Author

Choose a reason for hiding this comment

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

I will work on this so it works with hex and zip files too

src/components/ControlPanel.tsx Show resolved Hide resolved
src/components/MemoryBoxView.tsx Outdated Show resolved Hide resolved
src/util/devices.ts Outdated Show resolved Hide resolved
src/util/devices.ts Outdated Show resolved Hide resolved
src/util/devices.ts Outdated Show resolved Hide resolved
resources/css/canvas.scss Outdated Show resolved Hide resolved

const Canvas = () => {
const canvasRef = useRef<HTMLCanvasElement>(null);
const [c, setContext] = useState<CanvasRenderingContext2D | null>(null); // Why could this be |null ?
Copy link
Author

@jesper2k jesper2k Aug 30, 2022

Choose a reason for hiding this comment

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

There are a lot of places in this file where "c" (the canvas reference) and its properties could be null because it's not rendered yet, which is a common problem here. See my comment in the PR for details.

Copy link
Author

@jesper2k jesper2k left a comment

Choose a reason for hiding this comment

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

Looked at feedback from Pascal, reverted some unneeded changes.

@jesper2k jesper2k requested review from linegroe and removed request for linegroe August 30, 2022 14:49
@jesper2k
Copy link
Author

jesper2k commented Sep 20, 2022

Since most of the "1 frame delay" problems are just visual, I have mainly focused on trying to keep the element width fixed, as that solves a related "update oscillator" crashing problem. Tried doing it in code first, but just keeping the scrollbar visible at all times seemed to be simplest. I asked Ketil how he prefers the scrollbar layout, though the compact (2nd image) solution is a bit more tricky to implement because it needs to overwrite a react bootstrap (edit: or shared?) Card property, but I'm sure I'll figure it out 😃

image

image

I've also been working on trying to make the tooltip update when you scroll (and don't move the mouse), but it seems like it's a bit complicated given that they're two different event signatures.

@jesper2k
Copy link
Author

Some thoughts regarding colors in the visualization:

Currently they are just arbitrary (but deterministic) colors, but i guess it's kind of useful because it makes it clear when you're looking at a different file (because the largest sections will often have different colors, and it's easy to see which section is currently selected.

Would it be preferable for the colors to indicate the semantics of each section, like "this section is debug stuff, therefore it's red"? This would make it more difficult to distinguish between sections close to each other, which are often similar.

I know these are mostly Ketil-questions, but I'm just putting them out here to get ideas or suggestions on what you'd prefer.

resources/css/canvas.scss Show resolved Hide resolved
resources/css/section-info-view.scss Outdated Show resolved Hide resolved
resources/css/section-info-view.scss Outdated Show resolved Hide resolved
addMruFile(filePath);
// License for elfy can be found at https://github.com/indutny/elfy
/* eslint-disable global-require */
const elfy = require('elfy');
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a reason for using an inline require instead of a global import statement.

src/actions/fileActions.ts Show resolved Hide resolved
src/actions/targetActions.ts Outdated Show resolved Hide resolved
src/components/AppMainView.tsx Outdated Show resolved Hide resolved
src/reducers/elf.ts Show resolved Hide resolved
src/reducers/fileReducer.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants