TL;DR. sendNativeMessage in Safari returns exactly one reply. To stream a model's output through it,
the background script asks "anything after character N?" in a loop, and the Swift side holds each
request for up to a second until the text grows. Every reply carries the whole text so far, counted in
UTF-16. Then keep the background script alive yourself, and don't write to storage.session per poll.
I'm working on Epitome, a Safari extension for Mac, iPhone and iPad. It summarizes the current page with
the model Apple ships on the device (the Foundation Models framework).
On my MacBook Pro with an M5 Pro the first words come back after about two seconds, and a summary of a
long article takes 8 to 15. These are my numbers, not a benchmark: on other Macs and on iPhones they'll
be different.
When I tried showing nothing for 15 seconds and then the whole text at once, it felt like the extension
had hung.…