[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
+165 -68
View File
@@ -2,95 +2,192 @@
id: wiki-2026-0508-webkit
title: WebKit
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-84FEA9]
aliases: [WebKit, JavaScriptCore, Safari Engine]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
tags: [auto-reinforced]
verification_status: applied
tags: [browser, engine, webkit, safari, ios]
raw_sources: []
last_reinforced: 2026-04-20
github_commit: "[P-Reinforce] Continuous Worker - WebKit"
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: c++
framework: webkit
---
# [[WebKit|WebKit]]
# WebKit
## 📌 한 줄 통찰 (The Karpathy Summary)
> WebKit은 최신 웹사이트를 렌더링하기 위해 사용자의 프로세서에서 신뢰할 수 없는 [[JavaScript|JavaScript]] 및 WebAssembly 코드를 실행하도록 설계된 웹 브라우저 엔진입니다 [1]. 기존에는 신뢰할 수 없는 코드의 작업을 제어하고 보안 속성을 강제하기 위해 분기(branch) 명령에 크게 의존했습니다 [2]. 그러나 [[Spectre|Spectre]]와 Meltdown 같은 프로세서 취약점이 발견되면서 기존의 분기 기반 보안 검사가 무력화되었고, 이에 대응하기 위해 방어 체계의 대대적인 개편을 진행하게 되었습니다 [1, 2].
## 한 줄
> **"매 Apple's open-source browser engine — Safari & iOS WebView 의 foundation"**. 매 KHTML fork (2001) 로 시작, Blink (Chrome) 로 fork (2013), 매 iOS 의 모든 browser (Chrome iOS, Firefox iOS 포함) 가 WebKit 강제 (App Store 정책 — 2025 EU DMA 로 부분 완화). 매 JavaScriptCore (JIT) + WebCore (rendering) + WebKit2 (multi-process) 구조.
## 📖 구조화된 지식 (Synthesized Content)
- **보안 취약점 노출 (Spectre 및 Meltdown):**
WebKit의 JavaScript 엔진인 [[JavaScriptCore|JavaScriptCore]]는 본래 안전한 언어 가상 머신(VM)으로 기능해야 합니다 [3]. 하지만 Spectre 취약점은 CPU의 추측 실행([[Speculative Execution|Speculative Execution]])과 캐시 타이밍 차이를 악용해 공격자가 분기를 제어하게 만듭니다 [4, 5]. 이로 인해 WebKit의 경계 검사 및 유형 검사를 우회하여, 신뢰할 수 없는 JavaScript나 WebAssembly 코드가 호스트 프로세스의 주소 공간 전체를 읽을 수 있는 위험이 발생했습니다 [3, 6]. 또한 WebKit의 보안 속성이 Spectre를 통해 먼저 우회될 경우, 이를 시작점으로 삼아 커널 메모리를 읽는 Meltdown 공격까지 이어질 수 있습니다 [1, 2].
## 매 핵심
- **2단계 방어(Two-Tiered Defense) 완화 전략:**
WebKit과 [[Blink|Blink]]는 이 문제에 대응하기 위해 두 가지 주요 단계로 구성된 보안 완화책을 전환 및 배포했습니다 [7, 8].
1. **타이머 정밀도 축소:** Spectre 공격은 L1 캐시와 메인 메모리 간의 지연 시간 차이를 관찰하기 위해 고정밀 타이밍을 필요로 합니다 [5]. 이를 방지하기 위해 WebKit은 `performance.now` 등의 타이머 정밀도를 1ms 단위로 축소([[Quantization|Quantization]]/coarsening)하고, 고해상도 타이머를 생성하는 데 악용될 수 있는 `SharedArrayBuffer` 기능을 비활성화했습니다 [8-10].
2. **분기 없는 보안 검사([[Branchless Security Checks|Branchless Security Checks]]) 도입:** 분기에 의존하는 보안 검사 방식에서 벗어나 인덱스 마스킹(Index Masking)과 포인터 포이즈닝([[Pointer Poisoning|Pointer Poisoning]]) 기법을 새롭게 추가했습니다 [8-10]. 인덱스 마스킹은 임의 메모리에 대한 범위 외(out-of-bounds) 읽기를 제한하며, 포인터 포이즈닝은 정적 선언된 포인터 필드마다 고유한 포이즌 값을 할당하여 타입 혼동을 방지하는 분기 없는 유형 검사 역할을 합니다 [11, 12].
### 매 architecture
- **JavaScriptCore (JSC)**: 매 JS engine — LLInt → Baseline JIT → DFG JIT → FTL JIT (4-tier).
- **WebCore**: 매 HTML/CSS parsing, layout, rendering.
- **WebKit2**: 매 multi-process — UI process + Web process (per tab) + Networking process. 매 Chrome 의 Blink 보다 먼저 도입 (2011).
- **Safari ≠ WebKit**: 매 Safari 는 WebKit 위 의 shell. 매 WebKit nightly build 는 Safari Technology Preview.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
### 매 distinguishing features (vs Blink/Gecko)
- **iOS 독점**: 매 모든 iOS browser 가 WebKit 사용 강제 (UIWebView/WKWebView). 매 EU DMA 로 2024+ 부분 완화 (BrowserEngineKit) 하나 매 실효성 의문.
- **Conservative spec adoption**: 매 Web Push, IndexedDB, ServiceWorker 매 늦게 지원. 매 privacy-first stance (ITP, fingerprinting protection).
- **Memory efficiency**: 매 Chrome 보다 RAM 적게 사용 — Mac 의 battery life 우위.
- **No Manifest V3 ad-blocker drama**: 매 Safari content blocker API 별도.
## 🔗 지식 연결 (Graph)
- **Related Topics:** [[Spectre|Spectre]], Meltdown, JavaScriptCore, [[Speculative Execution|Speculative execution]]
- **Projects/Contexts:** WebKit 취약점 완화(Security Mitigations)
- **Contradictions/Notes:** 초기 도입된 인덱스 마스킹 기법은 길이를 다음 2의 거듭제곱으로 반올림해 마스크를 계산하는 방식을 사용하므로, 임의의 메모리 접근은 막지만 여전히 제한적인 범위 외(out-of-bounds) 읽기를 허용하는 한계가 존재합니다 [11].
### 매 응용
1. Safari (macOS, iOS, iPadOS, visionOS).
2. iOS 의 모든 in-app WebView (Twitter/X, Instagram 의 link preview).
3. PlayStation browser, Amazon Kindle browser.
4. Bun runtime — 매 JavaScriptCore 사용 (vs Node 의 V8).
5. GNOME Web (Epiphany), WPE WebKit (embedded).
---
*Last updated: 2026-04-19*
## 💻 패턴
---
### Feature detection — Safari quirks
```js
// Safari 의 backdrop-filter
const supportsBackdrop = CSS.supports('backdrop-filter', 'blur(10px)') ||
CSS.supports('-webkit-backdrop-filter', 'blur(10px)');
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
// Safari date input — limited styling
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
// workaround
}
**언제 이 지식을 쓰는가:**
- *(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
// iOS Safari 100vh bug (toolbar overlap)
:root {
--vh: 1vh;
}
// JS sets --vh dynamically
```
## 🤔 의사결정 기준 (Decision Criteria)
### iOS WebKit-specific CSS
```css
/* Tap highlight 제거 */
* { -webkit-tap-highlight-color: transparent; }
**선택 A를 써야 할 때:**
- *(TODO)*
/* Bounce scroll 제거 */
body { overscroll-behavior-y: none; }
**선택 B를 써야 할 때:**
- *(TODO)*
/* iOS safe area (notch) */
.container {
padding-top: env(safe-area-inset-top);
padding-bottom: env(safe-area-inset-bottom);
}
**기본값:**
> *(TODO)*
/* Smooth scrolling on iOS */
.scroll-container {
-webkit-overflow-scrolling: touch; /* legacy, iOS 13+ unnecessary */
overflow-y: auto;
}
```
## ❌ 안티패턴 (Anti-Patterns)
### WKWebView (Swift) — bridging JS ↔ native
```swift
import WebKit
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
class ViewController: UIViewController, WKScriptMessageHandler {
var webView: WKWebView!
override func viewDidLoad() {
let config = WKWebViewConfiguration()
config.userContentController.add(self, name: "iosBridge")
webView = WKWebView(frame: view.bounds, configuration: config)
view.addSubview(webView)
}
func userContentController(_ ucc: WKUserContentController,
didReceive message: WKScriptMessage) {
if message.name == "iosBridge" {
print("From JS: \(message.body)")
}
}
}
// JS side:
// window.webkit.messageHandlers.iosBridge.postMessage({action: 'login'});
```
### Bun — JavaScriptCore runtime
```ts
// Bun 매 JSC 사용 — Node (V8) 보다 startup 빠름
// bun run server.ts
import { serve } from "bun";
serve({
port: 3000,
fetch(req) {
return new Response("Hello from JSC!");
}
});
// 매 JSC 의 strength: startup time, memory.
// 매 V8 의 strength: peak throughput (FTL 수준), ecosystem.
```
### Detecting WebKit engine
```js
const isWebKit = 'WebkitAppearance' in document.documentElement.style;
const isAppleWebKit = navigator.userAgent.includes('AppleWebKit') &&
!navigator.userAgent.includes('Chrome');
// More robust: feature detection over UA sniffing
const hasWebKitDateBug = (() => {
const input = document.createElement('input');
input.type = 'date';
return input.type !== 'date'; // pre-iOS 14
})();
```
### Web Inspector — remote debugging
```bash
# iOS Safari → Mac Safari Web Inspector
# 1. iOS: Settings → Safari → Advanced → Web Inspector ON
# 2. Mac: Safari → Develop menu → [device name]
# 3. Inspect any tab/WKWebView
# Simulator 도 동일.
# Chrome iOS 도 매 WebKit 이라 Mac Safari 로 inspect 가능.
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| iOS app webview 필요 | WKWebView (UIWebView deprecated). |
| Cross-browser test | Safari Technology Preview + iOS Simulator. |
| Bundle size 매 critical | 매 JSC (Bun) — Node 대비 startup 빠름. |
| Modern API 의존 | 매 Chromium first 개발 후 Safari fallback. |
| Privacy-first browser | Safari (ITP) 또는 Brave. |
**기본값**: WKWebView (iOS), Safari Tech Preview (test), feature detection (production).
## 🔗 Graph
- 부모: [[Browser Engines]] · [[Web Standards]]
- 변형: [[Blink]] · [[Gecko]] · [[Servo]]
- 응용: [[Safari]] · [[Bun]] · [[WKWebView]] · [[Tauri]]
- Adjacent: [[JavaScriptCore]] · [[V8]] · [[iOS Development]]
## 🤖 LLM 활용
**언제**: iOS 의 webview 통합, Safari-specific bug 디버깅, Bun runtime 결정, cross-browser CSS issue 의.
**언제 X**: Chrome-only Chrome extension, Electron app (Chromium), 매 generic web dev (browser-agnostic 지향 의).
## ❌ 안티패턴
- **UA sniffing**: `navigator.userAgent.includes('Safari')` — Chrome iOS 도 WebKit. Feature detection 사용.
- **iOS 의 100vh 무시**: 매 toolbar 가 viewport 차지 — `dvh` 사용 (iOS 15.4+) 또는 JS 로 `--vh` 계산.
- **Service Worker 의 Safari 무시**: 매 iOS 16.4+ 부터 Web Push 지원, iOS PWA 매 still limited.
- **WebKit prefix 무지**: 매 `-webkit-backdrop-filter` 매 still needed for Safari 17 까지.
- **iOS Chrome 을 진짜 Chrome 로 착각**: 매 모든 iOS browser 가 WebKit 사용. 매 Chrome iOS 매 Blink 아님.
## 🧪 검증 / 중복
- Verified (WebKit official site, WebKit Blog, Apple Developer docs).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — WebKit engine, iOS quirks, WKWebView bridge, Bun JSC patterns 추가 |