daily-tech:2026-12-05 現象: 上一篇我們把 Android 從 Linux 核心、 init 、 Zygote 到 SystemServer 的開機啟動鏈一路攤平;今天接著看系統進入日常運作後,工程師最常面對的兩種「現場凍住或瞬間退場」情境。你可能遇過這樣的畫面:手指在 App 上連點了幾下毫無反應,過幾秒跳出「應用程式沒有回應」(ANR, Application Not Responding);更棘手一點,整個畫面突然黑屏並直接退回開機動畫,卻沒有重跑硬體開機商標;又或者呼叫 C/C++ 原生函式庫(例如影像編解碼或端側推論引擎)的瞬間,App 連個 Java 例外都沒留下就直接閃退。 Symptom: In our previous post, we traced the Android boot chain from the Linux kernel through init , Zygote , and SystemServer . Today we examine what happens once the system is up and something freezes or vanishes. You have likely seen an app ignore taps for several seconds before popping up an "Application Not Responding" (ANR) dialog, or watched the entire UI cut back to the boot animation without a full hardware reboot, or seen an app vanish instantly while running C/C++ native code (such as media codecs or an edge inference engine) without throwing a Java exception. 這三種表面現象背後其實對應著三條截然不同的監控與崩潰機制:前景應用程式卡住走的是 InputDispatcher 逾時與 ANR 轉儲路徑 ;整機退回開機動畫通常是 SystemSe...
Android 開機啟動鏈拆解:從 init、Zygote 到 SystemServer 的行程孵化與服務註冊時序 / Android Boot Chain Deconstructed: Process Forking, Preloading, and Service Startup from init and Zygote to SystemServer
daily-tech:2026-12-04 現象: 上一篇我們拆解了系統跑起來之後,如何用 ftrace 與 perf 揪出核心延遲尖峰與鎖競爭熱點;今天我們把時間軸往回拉,對準按下電源鍵到桌面出現的那幾十秒。你可能遇過這樣的畫面:Android 手機做完系統更新重新開機,或是開發板剛燒錄好新映像檔,螢幕一直停在開機動畫打轉,既沒有直接當機重啟,也看不到哪個環節卡住了。究竟是 Linux 核心還沒交棒、磁碟分區掛載慢了、Zygote 預載類別太重,還是 SystemServer 裡某個系統服務在主執行緒卡死? Symptom: In our previous post, we used ftrace and perf to hunt down kernel latency spikes and lock contention on a running system. Today we rewind the clock to the tens of seconds between pressing the power button and seeing the home screen. You have likely seen an Android phone after an OS update—or a freshly flashed dev board—spin endlessly on the boot animation without crashing or revealing where time is going. Is the Linux kernel still handing off control, is partition mounting stalled, is Zygote preloading too much, or is a service inside SystemServer blocking the main thread? 想看懂開機時間花去哪裡,不能只把開機動畫當成一個黑盒子。整個 Android 使用者空間(Userspace)的誕生其實是一條高度有序的接力鏈:從 Linux 核心交出第一個使用者行程 init (PID 1) ,再由 init 喚起行程母體 Zygote 預先暖機 AR...