-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS 14 Widget #127
Comments
Good idea. It'd be a great chance for learning too. I hope somebody jumps in and works on this. |
I'd love to have this one too. |
Hello there! I've started working on some iOS 14 widgets for CoronaTracker, but I've hit a problem: the peak memory usage for a widget cannot exceed 30 Mb. Currently, getting all the data from @mhdhejazi , is there a simple way to fetch some basic data (ex. just the P.S: This is also the reason why the existing Today Extension is not working any more. |
Looks great! |
I think I managed to solve the issue... By looking at memory allocations, I've found that let dateStrings = headers.dropFirst(4)
if let date = dateFormatter.date(from: dateString) {
for confirmedTimeSeries in confirmed {
for column in confirmedTimeSeries.values.indices {
let dateString = dateStrings[dateStrings.startIndex + column]
if let date = dateFormatter.date(from: dateString) {
...
}
}
}
} All the calls to The solution was to parse only the header values as dates and use them later in the process (this also comes with a great performance improvement): let dateStrings = headers.dropFirst(4)
let dateValues = dateStrings.compactMap({ dateFormatter.date(from: $0) })
if let date = dateFormatter.date(from: dateString) {
for confirmedTimeSeries in confirmed {
for column in confirmedTimeSeries.values.indices {
let dateString = dateStrings[dateStrings.startIndex + column]
let date = dateValues[column]
...
}
}
} Managed to reduce the memory used by a widget to I still have to do a bit of more UI polishing and create a pull request (most likely tomorrow). |
Wow, great work there and a nice catch. When I created the app the dataset was relatively small (both horizontally and vertically), so I didn't see the memory and performance issue. Thank you for fixing that. Another idea to improve performance and memory usage could be by only parsing the data relevant to the current region. It could be challenging to do that without a big refactoring, but you can take a look at it. |
@mhdhejazi - just made a PR that only addresses the memory reduction stuff (#133) |
it seems its solved in #134 ? |
Any chance someone is working on a new iOS 14 home screen widget for the app?
Would love to be able to have my local numbers easily visible.
The text was updated successfully, but these errors were encountered: