Closed Bug 1230623 Opened 10 years ago Closed 10 years ago

Close our database connections in applicationWillTerminate

Categories

(Firefox for iOS :: Data Storage, defect)

All
iOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fxios 2.0+ ---

People

(Reporter: rnewman, Assigned: rnewman, Mentored)

References

Details

(Whiteboard: [uplift?])

Attachments

(1 file)

The belt-and-braces part of Bug 1230288. Potential follow-up from Bug 1228611 Comment 2.
We can fake an applicationWillTerminate by backgrounding the app with UIApplicationExitsOnSuspend = YES in Info.plist. That gives us a little bit of out-of-order stuff -- our usual backgrounding code runs -- but it still works: In normal operation aWT is called much later, so this is fine. [DEBUG] Did enter background [DEBUG] Did close IPv6 listening socket 8 [DEBUG] Did close IPv4 listening socket 7 [INFO] GCDWebServer stopped 2015-12-04 10:39:02.096 [Debug] [AppDelegate.swift:134] applicationWillTerminate > Application will terminate. 2015-12-04 10:39:02.116 [Debug] [Profile.swift:244] shutdown() > Shutting down profile. 2015-12-04 10:39:02.127 [Debug] [SwiftData.swift:424] deinit > deinit: closing connection on thread <NSThread: 0x12c61ade0>{number = 1, name = main}. 2015-12-04 10:39:02.135 [Debug] [SwiftData.swift:487] closeCustomConnection(immediately:) > Closing custom connection for /private/var/mobile/Containers/Shared/AppGroup/A84FCE11-91C9-4074-A0FC-5B72AC829F34/profile.profile/browser.db on <NSThread: 0x12c61ade0>{number = 1, name = main}. 2015-12-04 10:39:02.144 [Debug] [Profile.swift:237] background() > Backgrounding profile. 2015-12-04 10:39:02.149 [Debug] [SwiftData.swift:507] closeCustomConnection(immediately:) > Closed /private/var/mobile/Containers/Shared/AppGroup/A84FCE11-91C9-4074-A0FC-5B72AC829F34/profile.profile/browser.db. 2015-12-04 10:39:02.158 [Debug] [Profile.swift:226] logProfileFDs() > Open file descriptors:
Sorry, clearer logs without uncommitted code! 2015-12-04 10:44:24.849 [Debug] [Profile.swift:902] syncEverythingSoon() > Running delayed startup sync. 2015-12-04 10:44:25.009 [Warning] [Profile.swift:858] withSyncInputs(_:function:) > No account; can't sync. 2015-12-04 10:44:25.559 [Debug] [Profile.swift:770] endTimedSyncs() > Stopping sync timer. [DEBUG] Did enter background [DEBUG] Did close IPv6 listening socket 8 [DEBUG] Did close IPv4 listening socket 7 [INFO] GCDWebServer stopped 2015-12-04 10:44:25.589 [Debug] [Profile.swift:224] shutdown() > Shutting down profile. 2015-12-04 10:44:25.598 [Debug] [SwiftData.swift:424] deinit > deinit: closing connection on thread <NSThread: 0x157d31300>{number = 6, name = (null)}. 2015-12-04 10:44:25.609 [Debug] [AppDelegate.swift:134] applicationWillTerminate > Application will terminate. 2015-12-04 10:44:25.616 [Debug] [Profile.swift:224] shutdown() > Shutting down profile.
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
Attachment #8695985 - Flags: review?(etoop) → review+
master: edb7d40 Any strong opinions about uplifting this?
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
tracking-fxios: --- → ?
Flags: needinfo?(sarentz)
Flags: needinfo?(aaron.train)
Resolution: --- → FIXED
Whiteboard: [uplift?]
Target Milestone: --- → 2.0
No strong opinions, only questions. Will iOS call applicationWillTerminate just before device shutdown on battery depletion?
Flags: needinfo?(aaron.train)
That's pretty much the only purpose of applicationWillTerminate in iOS4+: if the app is in the foreground and is about to be terminated. Otherwise we get an equivalent notification for entering the background. Apparently aWT t can be called when we're recently backgrounded but need to be terminated (memory pressure?), but I don't know the precise circumstances.
I don't think the circumstances are spelled out, but memory pressure is probably the main reason. THe docs say we do get 5 seconds to clean up in applicationWillTerminate:
Flags: needinfo?(sarentz)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: