EntityQuery defaultResult is not called again when new widgets are added. Shows stale data.

I'm converting my app to use the new AppIntent system in the widgets from the old custom intent based system. I'm trying to implement defaultResult in my EntityQuery, so the widget can be ready to go as soon as it's added to the home screen.

https://developer.apple.com/documentation/widgetkit/making-a-configurable-widget

https://developer.apple.com/documentation/appintents/uniqueappentityprovider/defaultresult()

But the weird behavior is that defaultResult seems to be called once when the first widget is added to a home screen, and shows the correct data, but then the defaultResult method is never called again when subsequent widgets are added.

It just uses the result from when the first widget was added. This especially causes issues because then a user will delete the item that the first widget was referencing, but adding new widgets still try to refer to the old AppEntity that no longer exists, even though "entities(for " returns nil for those IDs to signify that item no longer exists.

I would have assumed defaultResult would get called every time a new widget is added, but haven't seen anyone else complain about this. Has anyone seen this issue before or have any advice?

This likely is happening to Widgets of the same kind. Can you try using different kind's for each to see if this is the issue, as well as file a bug report and reply here with the number?

Rico

WWDR - DTS - Software Engineer

@Engineer I've filed a feedback with a simple example project, as well as screen recordings showing the behavior.

Feedback: FB15592256

I also went ahead and duplicated the entire widget, making a second widget with a different "kind" but as can be seen in my screen recording video in the feedback, even the 2 different widgets of different "Kinds" still exhibit this problem and use the old invalid data from the other widget.

I've also uploaded the screen recordings and sample project to my Google Drive if anyone else wants to take a look or reproduce.

https://drive.google.com/drive/folders/1rC413RFtUP5AoBZQy7plaFEABMcKJZvh?usp=sharing

The same in my project. I have 2 widgets. It works for one and doesn't work for another. defaultResult func called in widget that requires a single value and not called in a widget with array

EntityQuery defaultResult is not called again when new widgets are added. Shows stale data.
 
 
Q