Skip to content
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

GoalViewController crashes when logging out and then logging in again #590

Closed
theospears opened this issue Dec 30, 2024 · 5 comments · Fixed by #591
Closed

GoalViewController crashes when logging out and then logging in again #590

theospears opened this issue Dec 30, 2024 · 5 comments · Fixed by #591
Labels
BUG Opposite of feature

Comments

@theospears
Copy link
Collaborator

From #537 (comment)

unfortunately that has the side effect of the app crashing when accessing goal.lastModifiedLocal at GoalViewController.updateLastUpdatedLabel upon signing into the app.

GoalManager.performPostGoalUpdateBookkeeping posts notification goalsUpdated
GoalViewController.onGoalsUpdatedNotification executes
calling its updateInterfaceToMatchGoal
GoalViewController.updateInterfaceToMatchGoal calls, among others, updateLastUpdatedLabel
GoalViewController.updateLastUpdateLabel now accesses self.goal.lastModifiedLocal, which at the time, is still part of an empty NSManagedObject Goal:

<Goal: 0x600002148aa0> (entity: Goal; id: 0xblahblahblah9494 x-coredata://blahblah-F9F9-4FB3-BD1B-blahblah/Goal/p385; data: {
alertStart = nil;
autodata = nil;
data = "<relationship fault: 0x600000383740 'data'>";
deadline = nil;
graphUrl = nil;
healthKitMetric = nil;
hhmmFormat = nil;
id = nil;
initDay = nil;
lastModifiedLocal = nil;
lastTouch = nil;
leadTime = nil;
limSum = nil;
owner = nil;
pledge = nil;
queued = nil;
recentData = "<relationship fault: 0x6000003829a0 'recentData'>";
safeBuf = nil;
safeSum = nil;
slug = nil;
thumbUrl = nil;
title = nil;
todayta = nil;
urgencyKey = nil;
useDefaults = nil;
won = nil;
yAxis = nil;
})

@theospears
Copy link
Collaborator Author

The XCode memory debugger suggests the view is being kept around by references from an NSTimer (presumably for updateLastUpdatedLabel) and NotificationCenter (presumably for onGoalsUpdatedNotification)

image

@krugerk
Copy link
Contributor

krugerk commented Dec 31, 2024

I still see it.

Steps to reproduce:
logged in, with goals
from the gallery, open a goal
from the goal, return to the gallery
this triggers automatically a fetch goals and updates the db
open another goal (in particular, before the gallery has been reloaded with goals after their recent fetch)
app crashes on the nil self.goal.lastModifiedLocal in GoalViewController.updateLastUpdatedLabel

@theospears
Copy link
Collaborator Author

I've tried the instructions above and been unable to reproduce. Could you provide any more detail? e.g. device vs simulator, ios version, etc.

@krugerk
Copy link
Contributor

krugerk commented Jan 2, 2025

I've tried the instructions above and been unable to reproduce. Could you provide any more detail? e.g. device vs simulator, ios version, etc.

Best I can do so far is

Last Exception Backtrace:
0   CoreFoundation                	       0x1804b9100 __exceptionPreprocess + 160
1   libobjc.A.dylib               	       0x180092da8 objc_exception_throw + 72
2   CoreData                      	       0x186d9d024 _PFManagedObject_coerceValueForKeyWithDescription + 1556
3   CoreData                      	       0x186da33f0 _sharedIMPL_setvfk_core + 176
4   BeeKit                        	       0x102c6b66c DataPoint.init(context:id:goal:json:) + 572 (DataPoint.swift:59)
5   BeeKit                        	       0x102c6b420 DataPoint.__allocating_init(context:id:goal:json:) + 72
6   BeeKit                        	       0x102c6bb30 static DataPoint.fromJSON(context:goal:json:) + 1104 (DataPoint.swift:77)
7   BeeKit                        	       0x102c999f0 closure #1 in Goal.updateToMatch(json:) + 300 (Goal.swift:178)
8   BeeKit                        	       0x102c99a84 partial apply for closure #1 in Goal.updateToMatch(json:) + 28
9   BeeKit                        	       0x102c6a2a8 Collection.map<A, B>(_:) + 1504
10  BeeKit                        	       0x102c99720 Goal.updateToMatch(json:) + 4872 (Goal.swift:177)
11  BeeKit                        	       0x102c980e4 Goal.init(context:owner:json:) + 884 (Goal.swift:132)
12  BeeKit                        	       0x102c97d60 Goal.__allocating_init(context:owner:json:) + 56
13  BeeKit                        	       0x102c807c0 GoalManager.updateGoalsFromJson(_:) + 1632 (GoalManager.swift:110)
14  BeeKit                        	       0x102c7e908 GoalManager.refreshGoals() + 284 (GoalManager.swift:65)
15  BeeSwift.debug.dylib          	       0x102eba885 closure #1 in GalleryViewController.fetchGoals() + 1 (GalleryViewController.swift:327)
16  BeeSwift.debug.dylib          	       0x102ebb051 partial apply for closure #1 in GalleryViewController.fetchGoals() + 1
17  BeeSwift.debug.dylib          	       0x102ea0495 thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
18  BeeSwift.debug.dylib          	       0x102ea05f1 partial apply for thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
19  libswift_Concurrency.dylib    	       0x2493a5829 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1

Simulator was an iPad M4 with iOS 18.2.
App was first launched from Xcode.
App was force quit then launched from the Home Screen.
Upon navigating from the gallery to a goal and back to the gallery then logging out, the app disappeared and the aforementioned trace was presented.

@theospears
Copy link
Collaborator Author

theospears commented Jan 3, 2025

Thanks for providing the stack. To confirm my understanding, I think this is a different crash from the one talk about in #590 (comment) ?

app crashes on the nil self.goal.lastModifiedLocal in GoalViewController.updateLastUpdatedLabel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Opposite of feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants