[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
+134 -65
View File
@@ -2,91 +2,160 @@
id: wiki-2026-0508-electron
title: Electron
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-687305]
aliases: [Electron Framework, Atom Shell]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
tags: [auto-reinforced]
verification_status: applied
tags: [desktop, javascript, chromium, nodejs]
raw_sources: []
last_reinforced: 2026-04-20
github_commit: "[P-Reinforce] Continuous Worker - Electron"
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: unspecified
framework: unspecified
language: TypeScript/JavaScript
framework: Electron 33+
---
# [[Electron]]
# Electron
## 📌 한 줄 통찰 (The Karpathy Summary)
> Electron은 대규모 CAD 애플리케이션 등에서 사용되는 런타임 환경으로, 전체 시스템 메모리에 접근할 수 있지만 격리된 프로세스 간에 메모리를 관리해야 하는 특징이 있습니다 [1, 2]. [[Chromium]] GPU 프로세스와 렌더러 프로세스가 분리되어 있어 GPU 메모리 누수나 OOM(Out of [[memory]]) 오류가 발생하기 쉬운 구조적 위험성을 내포하고 있습니다 [3, 4].
## 한 줄
> **"매 Chromium + Node.js를 묶어 web tech 으로 desktop app 을 build"**. GitHub 이 Atom editor 용으로 만든 framework 가 VS Code, Slack, Discord, Figma desktop, 1Password 의 backbone 이 되었음. 2026 현재 Electron 33+ 가 process model 강화 (utility process), V8 sandbox, ASAR integrity 검사 의 기본화.
## 📖 구조화된 지식 (Synthesized Content)
- **메모리 관리의 양날의 검**: 대규모 CAD 애플리케이션을 Electron에서 구동할 때, 전체 시스템 메모리에 접근할 수 있다는 장점이 있지만 프로세스가 격리되어 있어 메모리 관리에 세심한 주의가 필요합니다 [2]. 예를 들어 메인 스레드와 Web Worker 간에 'Structured Cloning' 방식으로 메시지를 전달할 경우, 데이터가 전체 복사되어 메모리 사용량이 두 배로 증가할 수 있으며 이로 인해 Electron의 OOM(Out of Memory) 킬러가 작동할 수 있습니다 [3].
- **GPU 메모리 누수 취약성**: Electron 앱은 Chromium GPU 프로세스가 렌더러 프로세스와 완전히 분리되어 있기 때문에 GPU 메모리 누수로 악명이 높습니다 [4]. 3D 씬에서 객체를 삭제하더라도 단순히 씬 그래프에서 제거하는 것만으로는 연관된 GPU 버퍼가 자동으로 해제되지 않습니다 [4].
- **최적화 및 안정성 확보 전략**: Electron 런타임 환경 내에서 메모리 안정성을 유지하기 위해서는 `SharedArrayBuffer`를 활용하여 데이터 복제 오버헤드 없이 다중 스레딩을 처리해야 합니다 [1, 3]. 더불어 메모리 누수를 막기 위해, 삭제 시 씬을 순회하며 모든 기하학적 구조와 재질에 대해 명시적으로 `.dispose()`를 호출하는 엄격한 리소스 폐기(Disposal) 패턴을 강제해야 합니다 [4].
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
### 매 process model
- **Main process**: Node.js runtime, app lifecycle, native API (file, dialog, tray) 의 owner. 매 1 개 instance.
- **Renderer process**: Chromium tab 마다 1 개. BrowserWindow content. Sandbox 기본 ON (Electron 20+).
- **Preload script**: Renderer 의 isolated world 에서 실행, `contextBridge` 로 main 과 안전 bridge.
- **Utility process**: 매 v22+ 추가. Heavy CPU/IO offload (image decode, ffmpeg).
## 🔗 지식 연결 (Graph)
- **Related Topics:** SharedArrayBuffer, OOM (Out of Memory), Chromium GPU process
- **Projects/Contexts:** Large-scale CAD applications, [[WebGL]]/Three.js Rendering [[Optimization]]
- **Contradictions/Notes:** 소스에 Electron 프레임워크 자체의 전반적인 동작 원리나 일반적인 데스크톱 앱 개발과 관련된 정보가 부족합니다. 제공된 문서는 대규모 3D/CAD 렌더링 최적화 환경에서의 메모리 관리 및 누수 문제에 국한하여 Electron을 설명하고 있습니다.
### 매 IPC 패턴
- `ipcRenderer.invoke``ipcMain.handle` (Promise-based, 권장).
- `ipcRenderer.send``ipcMain.on` (fire-and-forget).
- `webContents.send``ipcRenderer.on` (main → renderer push).
-`contextIsolation: true` + `nodeIntegration: false` 의 mandatory.
---
*Last updated: 2026-04-19*
### 매 응용
1. **Editor**: VS Code, Atom, Obsidian.
2. **Communication**: Slack, Discord, Microsoft Teams.
3. **Design**: Figma desktop, Notion.
4. **Crypto/Wallet**: 1Password, Exodus.
---
## 💻 패턴
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### Secure preload bridge
```typescript
// preload.ts
import { contextBridge, ipcRenderer } from 'electron'
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
contextBridge.exposeInMainWorld('api', {
readFile: (path: string) => ipcRenderer.invoke('fs:read', path),
onUpdate: (cb: (v: string) => void) => {
const listener = (_: unknown, v: string) => cb(v)
ipcRenderer.on('app:update', listener)
return () => ipcRenderer.removeListener('app:update', listener)
},
})
```
## 🤔 의사결정 기준 (Decision Criteria)
### Main IPC handler with validation
```typescript
// main.ts
import { ipcMain, app } from 'electron'
import { promises as fs } from 'node:fs'
import path from 'node:path'
**선택 A를 써야 할 때:**
- *(TODO)*
ipcMain.handle('fs:read', async (_event, requested: string) => {
const userData = app.getPath('userData')
const resolved = path.resolve(userData, requested)
if (!resolved.startsWith(userData)) throw new Error('path traversal')
return await fs.readFile(resolved, 'utf-8')
})
```
**선택 B를 써야 할 때:**
- *(TODO)*
### BrowserWindow secure defaults
```typescript
import { BrowserWindow } from 'electron'
import path from 'node:path'
**기본값:**
> *(TODO)*
const win = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false,
sandbox: true,
webSecurity: true,
},
})
```
## ❌ 안티패턴 (Anti-Patterns)
### Auto-updater (electron-updater)
```typescript
import { autoUpdater } from 'electron-updater'
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
autoUpdater.checkForUpdatesAndNotify()
autoUpdater.on('update-downloaded', () => autoUpdater.quitAndInstall())
```
### Utility process offload
```typescript
import { utilityProcess, MessageChannelMain } from 'electron'
const { port1, port2 } = new MessageChannelMain()
const child = utilityProcess.fork(path.join(__dirname, 'worker.js'))
child.postMessage({ task: 'transcode' }, [port2])
port1.on('message', (msg) => console.log('result', msg))
```
### Code signing build (electron-builder)
```json
{
"build": {
"appId": "com.example.app",
"mac": { "hardenedRuntime": true, "gatekeeperAssess": false, "notarize": true },
"win": { "signingHashAlgorithms": ["sha256"] },
"asar": true
}
}
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Cross-platform desktop, web team | Electron |
| Bundle size critical (<50MB) | Tauri (Rust) 고려 |
| Native feel mandatory | Native (Swift/Kotlin) |
| Existing web app → wrap | Electron |
| Mobile target 도 필요 | React Native / Flutter |
**기본값**: 매 Electron 33+ + contextIsolation + electron-builder + auto-updater.
## 🔗 Graph
- 부모: [[Chromium]] · [[Nodejs]]
- 변형: [[Tauri]] · [[NW.js]]
- 응용: [[VS Code]] · [[Slack Desktop]]
- Adjacent: [[Chrome DevTools(크롬 개발자 도구)]] · [[V8 엔진 힙 아키텍처]]
## 🤖 LLM 활용
**언제**: web stack 재사용, 빠른 cross-platform delivery, rich web-based UI 필요.
**언제 X**: 매 100MB+ binary 가 unacceptable, 매 deep OS integration (kernel ext, system tray 만 의 limit), battery-critical mobile.
## ❌ 안티패턴
- **nodeIntegration: true with remote content**: 매 RCE risk. 매 contextIsolation 강제.
- **`require('electron').remote`**: deprecated, removed v14+. `@electron/remote` 도 안티 — IPC handle 로 교체.
- **불특정 origin loadURL**: 매 untrusted web 을 BrowserWindow 에 load 하면 sandbox escape 위험.
- **ASAR 만 의 protection**: ASAR 는 압축 일 뿐. Source 보호 의 X — 매 native module / 서버 side 로 logic 이동.
## 🧪 검증 / 중복
- Verified (electronjs.org docs, Electron 33 release notes 2026).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Electron 33 process model + secure IPC patterns |