Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Profiling

Flutter cold start: measuring the time before your first frame

“The app takes three seconds to open” is a complaint, not a measurement. Three seconds from what — the tap, the process spawning, the engine coming up, or the moment your main() runs? Each of those is a different problem with a different fix, and optimising the wrong one is how teams spend a sprint moving startup from 2.9 s to 2.8 s. Cold start in a Flutter app has four phases, and they are separable. The four phases 1. Process launch. The OS creates the process, loads the executable and its shared libraries, and hands control to the platform runner. Nothing in your Dart code affects this. What does affect it is binary size (see the app size discussion) and, on Android, the number of libraries to link. 2. Engine initialisation. The Flutter engine starts, the Dart VM comes up, and — in release builds — the AOT snapshot is mapped in. Plugin registration happens on the platform side here. 3. Dart main() to runApp() . Your code. This is the phase you control completely, and the o...

Impeller và một frame bị giật: tìm xem 16ms đã trôi đi đâu

Tester báo bug: “danh sách sản phẩm bị giật khi cuộn nhanh trên máy Pixel”. Bạn tìm flutter jank , ba kết quả đầu tiên đều bảo chạy flutter run --profile --cache-sksl , lấy file SkSL rồi nhét vào bản release. Bạn làm theo. Cái flag đó không còn, hoặc bị bỏ qua, và chỗ giật vẫn nguyên vẹn. Lời khuyên đó đúng — với Skia. Nó không đúng với app của bạn, vì app của bạn gần như chắc chắn đang render bằng Impeller, và Impeller không hề biên dịch shader lúc runtime. Tài liệu Flutter nói thẳng: Impeller “precompiles a smaller, simpler set of shaders at engine-build time so they don’t compile at runtime”. Không có gì để warm up cả. Quy trình --cache-sksl và --bundle-sksl-path là cơ chế riêng của Skia, và issue #140310 tồn tại chính vì có quá nhiều người cố dùng nó với Impeller. Vậy là cả một nhóm nguyên nhân gây jank đã biến mất. Các nhóm còn lại thì không. Một build() đi parse JSON vẫn chậm. Một IntrinsicHeight bọc quanh Row lớn vẫn là thêm một lượt layout. Canvas.saveLayer vẫn là, the...

Impeller and a janky frame: how to find where the 16ms actually went

A tester files a bug that says “the product list stutters when I scroll fast on the Pixel.” You search for flutter jank , and the first three results tell you to run flutter run --profile --cache-sksl , capture an SkSL file, and bundle it into your release build. You try it. The flag is gone, or it is ignored, and the stutter is exactly where it was. That advice was correct for Skia. It is not correct for your app, because your app is almost certainly rendering with Impeller, and Impeller does not compile shaders at runtime at all. The Flutter docs are direct about it: Impeller “precompiles a smaller, simpler set of shaders at engine-build time so they don’t compile at runtime.” There is nothing to warm up. The --cache-sksl and --bundle-sksl-path workflow is a Skia-only mechanism, and issue #140310 exists specifically because people kept trying to use it with Impeller. So one entire category of jank is gone. The other categories are not. A build() method that does JSON parsing is...