SwiftUI Widget not loading

Hello, I am building a SwiftUI app that implements a widget. The user can add different configurations inside the app and then he can choose one by editing the widget.
Everything works correctly for almost all of the possible configurations, the widget getTimeline function gets called, all the parameters are passed to the entry successfully and the widget displays.
However the problem appears for some specific configurations, as soon as the user sets the widget configuration by tapping on it, it gets stuck on the loading animation and shows no content.
The only thing that makes these configurations different is the view body. These configurations show more elements, such as Images and Text. I tried removing few elements and the widgets started working.
To make an example there's a widget configuration that is made by a ZStack with a VStack inside, containing 3 HStacks which again contain 1 Text and 1 Image each. Removing 2 HStacks and keeping only one makes the widget load.

Is there something I am missing?
Is there some limit to widgets view elements?
I even checked the ram usage and it appears to be around 10mb for each widget.
Also I noticed that rebooting the device makes the widget load.

Thanks in advance for any help.

Replies

I'm having the same issue. When my UI contains a few stacked elements the widget doesn't respond to an update, but when removing a part of the elements it does succesfully respond to reloads. My ram usage etc. is also all normal.

Did you manage to solve this?

I'm having the same issue. When my UI contains a few stacked elements the widget doesn't respond to an update, but when removing a part of the elements it does succesfully respond to reloads. My ram usage etc. is also all normal.
Did you manage to solve this?

Unfortunately not. I'm trying to find some sort of workaround but with no success.
The only solution for now seems to be to make lighter widgets, even if it is impossible in some cases.
Ok I finally found a workaround.
It certainly is not right and should not be done this way but it works, and very well.
In my case I needed 5 images and 5 texts. The widget was loading only with 5 elements.
So I simply took each image and I drew text on it through UIGraphics. Doing it this way I was able to reduce the UI elements and the widget only loaded 5 elements instead of 10, showing the content.

Hi Francesco P,
Thanks a lot for following up, this gave me different testing results, would you mind helping me in the right direction?
If so, you can send a hello to tempmailforwidgethelp@gmail.com
It's totally fine if you don't want to, but it would be greatly appreciated :)

I am sorry for bumping this post :( Wish I could PM users.

Thanks Apple for allowing us well to debug widgets hey. Getting a totally different behaviour from debug to release. The image doesn’t load on the AppStore version. All my users will go from free to paid and it will not work - and claim a refund. This app made less than $50 in 2 years with 30k dnl but people are just Mr Kraps. you’ve just wasted my only opportunity to convert my existing users to paid. Now they all gonna delete the app. Thanks a lot!