Wow, that was rough! The Widgets app had a really nasty issue. The app would freeze on startup. If you had too many contacts – boom! The fix was not easy. The “Contacts” widget had to be redesigned and rewritten. It would have been easier to delete the widget and create a different widget from scratch. I’m not sure where the motivation comes from, as the challenge was bit beyond my level as a developer. But somehow, this project is different. I stuck with it until I figured it out.
First, the problem had to be identified. A response of “works for me” wasn’t going to cut it. After receiving some messages from customers, it was determined that the “Contacts” widget couldn’t handle thousands of contacts. How was I supposed to know that? I am a developer. I don’t have that many friends. 🤪
Once the issue was identified, the fix was separated into five parts.
Too many event listeners — While it’s awesome to leverage existing JavaScript knowledge to build apps, there are significant drawbacks. There weren’t any crash reports for this issue. I couldn’t determine what was wrong. Was this a problem with Swift or with JavaScript? Not knowing where to start, any potential issues were researched. After reading about JavaScript performance, it became obvious that each contact didn’t need an event listener. Instead, one event listener covers the entire list of contacts.
Don’t grab contacts on first launch — For some customers, the first introduction to the Widgets app was not very welcoming. Just in general, it’s not good practice to ask for contact information before even using the app. This problem was resolved with a new setting. The “Contacts” widget can show contacts on startup, but only after that setting has been selected. Otherwise, a search field is presented — that’s smart!
If more than 100 contacts, don’t grab all of them — The widget is small. Even if 1000+ contacts could be displayed, that could be pretty awkward in such a small space. That’s why a cap of 100 contacts was added. This helps prevent the Widgets app from freezing. It also helps keep the “Contacts” widget from getting too crowded.
Don’t grab contact data until a contact is clicked — This was also a waste of resources. Even if 1000+ contacts could be displayed, and even if all 1000+ contacts could fit in a small space, it was not necessary to fetch every email or phone number on launch. Instead, the full contact information isn’t fetched until the contact is clicked — also smart!
Contact Search — With a cap of 100 contacts, there needed to be a way to filter the results. Now, with the 1.8 update, simply searching for a single letter can dramatically reduce the amount of contacts to display. From 26 letters, down to just 1, it’s very powerful.
That’s why it took more than a month to launch this update. I needed to get better. Looking back, whoa! I didn’t expect to be making widgets of such sophistication. Hopefully, as I get better, the widgets get even better too!
The “Audio Player” widget is an example of this growth. For two months, I had been struggling to add this widget. It seemed so deceptively simple, but it proved to be quite the challenge. It was tough, but the hard work shows. Lessons from the “Contacts” widget were applied to the “Audio Player” widget. What if a user has over 10,000 songs? Would the widget crash? Fortunately, it only plays one track at a time. It doesn’t attempt to list an entire iTunes library.
Sometimes I’ll just be listening to music that’s playing the background. Then, I’ll smile, knowing that the Widgets app is playing that music. I built that – cool!
Thanks to everyone that wrote feedback. While not every request was fulfilled, I did try to add as many new features as I could. Had you not written, I doubt I would have improved the “World Clock” or the “Text-to-Speech” widgets. When the “Text-to-Speech” app started speaking in foreign languages, I had such a good laugh. I did not expect that the Widgets app would do that.
Hopefully the app brings you joy too. You can read the version 1.8 update notes on the Mac App Store page for the Widgets app. The challenges don’t stop here. The plan is to keep going.