Added detailed documentation files for code of conduct, contributing guidelines, core concepts, features, and project structure in the documentation/ directory. Updated README.md to reference new documentation, expand feature descriptions, and clarify setup instructions.
2.5 KiB
Core Concepts
This document explains the core architectural concepts of the Nebula browser.
Main and Renderer Processes
Electron applications have two types of processes: the main process and one or more renderer processes.
-
Main Process: The main process, which runs the
main.jsscript, is the entry point of the application. It runs in a Node.js environment, meaning it has access to all Node.js APIs likefsfor file system access andipcMainfor communication. It is responsible for creating and managingBrowserWindowinstances, which are the application's windows. -
Renderer Process: Each
BrowserWindowruns its own renderer process. The renderer process is responsible for rendering web content—in Nebula's case, the browser's user interface (UI) built with HTML, CSS, and JavaScript. The renderer process does not have direct access to Node.js APIs for security reasons.
Inter-Process Communication (IPC)
Since the main and renderer processes are separate, they need a way to communicate. This is done through Inter-Process Communication (IPC).
-
ipcMainandipcRenderer: Electron provides theipcMainandipcRenderermodules for this purpose. The main process can listen for messages from the renderer process usingipcMain.handle, and the renderer process can send messages usingipcRenderer.invoke. -
Context Bridge and Preload Script: To securely expose APIs from the main process to the renderer process, Electron uses a preload script and the context bridge. The
preload.jsscript runs in a special environment that has access to both thewindowobject of the renderer process and Node.js APIs. ThecontextBridgeis used to expose specific functions from the preload script to the renderer process, ensuring that the renderer process cannot access powerful Node.js APIs directly.
Performance and GPU Management
-
Performance Monitoring: The
performance-monitor.jsmodule helps track the application's performance by monitoring metrics like memory usage and page load times. This is essential for identifying and addressing performance bottlenecks. -
GPU Configuration: The
gpu-config.jsandgpu-fallback.jsmodules manage GPU acceleration. Electron uses the system's GPU to render content, which can significantly improve performance. However, GPU drivers can sometimes be a source of instability. These modules allow Nebula to check the GPU status and apply fallbacks (like disabling hardware acceleration) if issues are detected, ensuring a more stable experience.