Cleans up header order/grouping for consistency: associated header, C/C++ system/standard library headers, library headers, platform-specific #includes.
Adds <cstring> where strlen, memcpy are being used: there are a bunch of places we use them transitively.
Applies linter-required cleanups. Disables linter on one file due to included RapidJson header. See https://github.com/flutter/flutter/issues/65676
This patch does not cover flutter/shell/platform/darwin. There's a separate, slightly more intensive cleanup for those in progress.
This class is meant to be thread safe. In fact, its headerdoc statement on
thread safety even mentions this. All fields on the class are readonly except
the child isolate preparer. This field is set during VM instantiated isolate
initialization. The VM may launch multiple isolate in the same isolate group on
at the same time (each on a VM backed thread pool thread). Attempting to set the
field without synchronization is a data race.
Fixes https://github.com/flutter/flutter/issues/49358
Fixes b/147798920
Isolate data may need to be deleted on the same thread where it was allocated.
In particular, the task observer set up in the UIDartState ctor must be removed
from the same message loop where it was added.
The engine had been using the same DartIsolate object as the root isolate data
and as the isolate group data. This object would be deleted when the isolate
group was shut down. However, group shutdown may occur on a thread associated
with a secondary isolate. When this happens, cleanup of any state tied to the
root isolate's thread will fail.
This change adds a DartIsolateGroupData object holding state that is common
among all isolates in a group. DartIsolateGroupData can be deleted on any
thread.
See https://github.com/flutter/flutter/issues/45578