Constructing a second FaceGroupAnalyzer while a first one is still alive registers the
framework's Core Data managed object model a second time. Core Data can then no longer resolve
+[MIManagedFace entity], and the process is terminated with SIGTRAP (exit status 133).
Three things make this worse than a normal API misuse:
It happens with completely separate working directories. The two instances are logically
independent — different directories, different stores, no shared state that the API surface
exposes. Nothing in the signature of init(workingDirectory:) suggests that two of them cannot
coexist, and the parameter's existence implies the opposite.
There is no way to detect or prevent it from a library. FaceGroupAnalyzer is not a
singleton and offers no way to ask whether an instance already exists in the process. Any two
independent subsystems in an app — say, a background analysis service and a foreground preview —
that each construct an analyzer will terminate the app. In my case the app must now enforce
single-instance access through its own serial queue and lock, which is a constraint the framework
imposes but does not state.
Construction alone does not fail, so the problem surfaces later and elsewhere. Both instances
construct successfully; Core Data only emits warnings at that point. The abort comes when both are
alive and one of them does real work (update() and reading the grouping). So the crash lands far
from its cause, in code that is individually correct.
Feedback: FB24174678