Files
2nd/10_Wiki/Topics/Frontend/Bridgeless_New_Architecture.md
2026-05-10 22:08:15 +09:00

164 lines
5.4 KiB
Markdown

---
id: wiki-2026-0508-bridgeless-new-architecture
title: Bridgeless New Architecture
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [React Native New Architecture, Fabric+TurboModules]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [react-native, architecture, jsi, fabric, turbomodules]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: javascript
framework: react-native
---
# Bridgeless New Architecture
## 매 한 줄
> **"매 async-bridge serialization 의 제거 — JS 와 native 의 direct memory call"**. 매 React Native 0.68 (Fabric, TurboModules) 부터 시작 → 0.74 default 로 출하된 architectural rewrite. 매 JSI (JavaScript Interface) 기반 synchronous interop 으로 60Hz/120Hz UI 동기화.
## 매 핵심
### 매 Old Bridge 의 한계
- 매 모든 native↔JS 호출 의 JSON serialize → batched async queue.
- 매 startup 에 module table 전체 의 eager registration.
- 매 60fps 의 16.67ms budget 에 round-trip ≥ 2 frames 의 발생.
- 매 frame-locked animation/gesture 의 jank.
### 매 New Architecture 의 3 pillars
1. **JSI**: C++ host object 의 JS-runtime direct binding. Hermes/JSC interchangeable.
2. **TurboModules**: native module 의 lazy load + sync invocation.
3. **Fabric**: shadow tree 의 C++ rewrite — concurrent rendering + thread-safe layout.
### 매 Codegen 의 역할
- 매 TS/Flow spec → C++/Java/ObjC scaffolding 의 자동 생성.
- 매 type safety + boilerplate 의 elimination.
## 💻 패턴
### TurboModule spec (TS)
```typescript
// NativeCalculator.ts
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
export interface Spec extends TurboModule {
add(a: number, b: number): number; // sync!
fetchUserAsync(id: string): Promise<{name: string}>;
}
export default TurboModuleRegistry.getEnforcing<Spec>('Calculator');
```
### Fabric component spec
```typescript
// MyViewNativeComponent.ts
import { codegenNativeComponent, ViewProps } from 'react-native';
import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes';
interface NativeProps extends ViewProps {
intensity: Int32;
color?: string;
}
export default codegenNativeComponent<NativeProps>('MyView');
```
### JSI host function (C++)
```cpp
// 매 native side 에서 JS function 의 expose
auto add = jsi::Function::createFromHostFunction(
rt, jsi::PropNameID::forAscii(rt, "add"), 2,
[](jsi::Runtime& rt, const jsi::Value&, const jsi::Value* args, size_t) {
return jsi::Value(args[0].asNumber() + args[1].asNumber());
});
rt.global().setProperty(rt, "add", std::move(add));
```
### Bridgeless mode 활성화
```javascript
// react-native.config.js
module.exports = {
project: {
ios: {},
android: {},
},
// 매 RN 0.74+ 부터 default true
reactNativeArchitectures: 'arm64-v8a,x86_64',
};
```
```ruby
# ios/Podfile
use_react_native!(
:path => config[:reactNativePath],
:fabric_enabled => true,
:new_arch_enabled => true,
)
```
### 매 sync layout measurement
```typescript
import { findNodeHandle, UIManager } from 'react-native';
// 매 Fabric 에서 sync measure 의 가능
const handle = findNodeHandle(ref.current);
UIManager.measureInWindow(handle, (x, y, w, h) => {
// 매 동일 frame 안에 layout 완료 의 보장
});
```
### Reanimated 3 worklet (JSI 활용)
```typescript
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';
const offset = useSharedValue(0);
const style = useAnimatedStyle(() => ({
transform: [{ translateX: withSpring(offset.value) }],
}));
// 매 UI thread 에서 worklet 의 directly run — bridge 없음
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 신규 RN app (2026) | Bridgeless default — 매 그대로 사용 |
| 매 legacy native module 다수 | Interop layer 의 활용 (자동 shim) |
| 매 60Hz+ animation 필요 | Reanimated 3 + Fabric 의 mandatory |
| 매 startup 시간 critical | TurboModule lazy init 의 활용 |
**기본값**: 매 RN 0.76+ 의 Bridgeless on by default — 매 비활성화 의 X.
## 🔗 Graph
- 부모: [[React_Native]] · [[React_Native_New_Architecture]]
- 변형: [[Fabric]] · [[Fabric_Renderer]] · [[TurboModules]] · [[JSI (JavaScript Interface)]]
- 응용: [[Hermes]] · [[Hermes_Engine]] · [[Codegen]]
- Adjacent: [[Cross-platform_Mobile_Development_Frameworks]] · [[Flutter]]
## 🤖 LLM 활용
**언제**: 매 RN 0.74+ green-field project, 매 native↔JS round-trip 의 perf bottleneck 진단, 매 Reanimated/Skia/Gesture-Handler 의 깊은 통합.
**언제 X**: 매 Expo Go (legacy bridge only) 환경, 매 unmaintained native module 에 의존하는 코드베이스.
## ❌ 안티패턴
- **매 mixed arch leak**: 매 NEW_ARCH_ENABLED 의 절반만 활성화 → 매 일부 module 의 silent fallback.
- **매 sync abuse**: 매 모든 호출 의 sync 화 → 매 JS thread 의 block.
- **매 Codegen skip**: 매 manual binding 의 작성 — 매 type drift 의 발생.
- **매 bridge pattern 재현**: 매 NativeEventEmitter 의 남용 — 매 JSI host object 의 selection.
## 🧪 검증 / 중복
- Verified (React Native 공식 docs reactnative.dev/architecture, RN 0.76 release notes 2024-10).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Bridgeless 의 JSI/Fabric/TurboModule pillars 정리 |