Web Excursions 2021-09-19
Deep dive into Electron’s main and renderer processes - Cameron Nokes
Central to Electron is the concept of two or more operating system level processes running concurrently — the “main” and “renderer” processes.
The most important thing to remember here is that processes’ memory and resources are isolated from each other.
This architectural decision originates from Chromium.
“Chromium is built like an operating system,
using multiple OS processes to isolate web sites from each other and from the browser itself.”
So each process “runs in its own address space,
is scheduled by the operating system, and
can fail independently.”
The main process is responsible for creating and managing BrowserWindow instances and various application events.
It can also do things like register global shortcuts,
create native menus and dialogs,
respond to auto-update events, and more.
“The basic rule is: if a module is GUI or low-level system related, then it should be only available in the main process.”
(Note that GUI here means native GUI, not HTML based UI rendered by Chromium).
The render process is responsible for running the user-interface of your app,
or in other words, a web page which is an instance of webContents.
All DOM APIs, node.js APIs, and a subset of Electron APIs (see graphic below) are available in the renderer.
[Comparing] a BrowserWindow with a renderer process.
A renderer process isn’t actually created until a window has a webContents instance in it.
one or more webContents can live in a single window.
a single window can host multiple webviews and
each webview is its own webContents instance and renderer process.
E.g., if you have a page with 2 webviews in it, you’ll have 3 renderer processes —
one for the parent hosting the 2 webviews, and then one for each webview
Electron uses interprocess communication (IPC) to communicate between processes — same as Chromium.
Electron also gives you the remote module, which allows you to, for example, use a main process module like Menu as if it were available in the renderer.
IPC [isn’t] using some networking protocol (e.g. tcp, http, or something crazier) underneath the hood
Chromium’s IPC documentation states that it uses “named pipes” as the underlying vehicle for IPC.
Named pipes allow for faster, more secure communication than a networking protocol could provide.
“Named pipes” are similar to “unnamed pipes” which are used when you do something like
ls | grep foo
.
CPU intensive tasks should run in a separate process —
not an existing renderer with a UI in it (because it’ll lock that UI up) and not the main.
The easiest way to do this is with Electron-remote.
[which] has a renderer process task pool that will split and balance a job across multiple processes.
Lost Perspective? Try This Linguistic Trick to Reset Your View
I’ve studied how subtle linguistic shifts can powerfully alter the content of our thoughts,
and subsequently change the way we feel
Aurelius writes of the power that people have over their own thoughts.
He provides the following astute advice:
ask yourself (roughly), ‘What is upsetting you at this moment?’
The phrasing is paramount – he did not write: ‘What is upsetting me?’
Rather, he advised asking himself this question from the perspective of an outsider,
using the second-person singular pronoun.
This process of reflecting on one’s self using parts of speech that are typically used to refer to other people – ie, second- or third-person pronouns, or even one’s own name – is distanced self-talk.
A mounting body of research by psychologists suggests that engaging in distanced self-talk can help us
to regulate our negative thoughts and emotions in a range of situations –
from working through a painful past experience to performing on a stressful upcoming task.
When using the second-person pronoun ‘you’ to reflect on ourselves,
we can move beyond our default, egocentric perspective, and
consider our thoughts and feelings from the stance of a more objective observer.
The practice has also been shown to promote wise reasoning,
increasing participants’ willingness to search for a compromise, and
leading them to recognise the limits of their own knowledge.
Explainer: The Recovery Partition
Until July 2011, with the release of Mac OS X 10.7 Lion, Macs didn’t have any Recovery Mode.
its nearest equivalent was single-user mode (SUM)
When Apple added Recovery Mode, it was kept on a hidden HFS+ volume.
Each disk is formatted into different partitions,
using a GUID Partition Table,
which gives its name to the standard top-level format of the disk, GPT.
HFS+ volumes are each separate partitions of the disk,
which are physically separate areas of storage.
APFS adds another layer into its structure: its partitions are properly known as containers, within which each APFS volume is stored.
This gives rise to endless confusion, as
an HFS+ volume is also a disk partition, while
an APFS volume is inside a container,
and it’s the container which is the disk partition.
Unfortunately not all of Apple’s documentation follows that convention, and as a result can confuse further.
versions of Mac OS X from 10.7 Lion to 10.12 Sierra had Recovery Partitions in HFS+ format.
macOS 10.13 High Sierra,
have retained the older HFS+ partition for its Recovery System.
When Mojave was released in 2018, APFS was supported on all types of bootable storage,
In addition to the hidden EFI partition (about which I will say no more),
there was a single APFS container, within which was the Recovery volume,
macOS 11 Big Sur brought changes to accommodate the new Recovery System on M1 Macs.
while Intel Macs boot into Recovery from their Recovery Volume inside their current boot container,
M1 Macs boot into Recovery from their Recovery Container on their internal SSD.
Monterey may be about to change this for M1 Macs,
which look set to return to the Intel pattern
of booting from the Recovery Volume inside their current boot container,
provided that’s macOS 12.
Borb – A Python library to read, write, and edit PDF files
Syzygies:
I am a math professor with a scanned exam grading workflow that
I hacked together as Bash scripts using various open source command line tools.
I feed all the exams through a sheet-fed scanner,
decode bar codes to identify problems and students,
add radio buttons for entering and tracking scores (0-6 per problem), and
create PDF "books" per problem for grading and annotating.
with a chapter for each score, and
students randomized within each chapter.
In the same spirit as "checking your work lets you work three times faster" this is actually both more consistent and faster that a single pass over paper.
Almost all of my attention is on the math, which I'm good at,
rather than locating problems and finding again the ones I know I misgraded, which I'm not good at.
Then each student's exam needs to be extracted from these problem PDFs, scores recorded, and annotations frozen.
There are cloud services for grading.
They're hopelessly primitive, with cloud lag.
Sysz – An fzf terminal UI for systemctl
zamadatix:
Does anyone know of a way or how to go about making a way to get and to bash autocomplete "systemctl status " with service names?
xyzzy_plugh:
This works for me out of the box. Your bash profile might not be sourcing systemd's /usr/share/bash-completion/completions/systemctl
or equivalent path.