@mentra/crust 3.5.0-dev.1367 → 3.5.0-dev.1372

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "platforms": ["apple", "android", "web"],
3
3
  "apple": {
4
- "modules": ["CrustModule"]
4
+ "modules": ["CrustModule"],
5
+ "appDelegateSubscribers": ["MacQuitAppDelegateSubscriber"]
5
6
  },
6
7
  "android": {
7
8
  "modules": ["com.mentra.crust.CrustModule"]
@@ -0,0 +1,29 @@
1
+ import ExpoModulesCore
2
+ import Foundation
3
+
4
+ /// Lets the iOS app on a Mac quit without running C++ static destructors.
5
+ ///
6
+ /// Quitting the Mac app runs `-[NSApplication terminate:]`, which calls `exit()`.
7
+ /// `exit()` destroys C++ statics while React Native's threads are still running,
8
+ /// so a network response that lands during quit locks React Native's
9
+ /// already-destroyed `NetworkReporter` mutex. That throws `std::system_error`, and
10
+ /// Sentry's terminate handler (sentry-cocoa 8.58) suspends every thread before
11
+ /// it reads dyld's image list. The suspended main thread holds dyld's loader lock
12
+ /// inside `exit()`, so the handler waits forever. The app stays alive and hidden,
13
+ /// still connected to the glasses, until someone kills it.
14
+ ///
15
+ /// On the Mac, once `applicationWillTerminate` has run, nothing is left to do but
16
+ /// exit, so the last `atexit` handler registered here ends the process with
17
+ /// `_exit` before any static destructor runs. `exit()` calls handlers in reverse
18
+ /// order of registration, so registering this last makes it run first. The
19
+ /// process exiting closes its Bluetooth connections.
20
+ public class MacQuitAppDelegateSubscriber: ExpoAppDelegateSubscriber {
21
+ public func applicationWillTerminate(_ application: UIApplication) {
22
+ guard ProcessInfo.processInfo.isiOSAppOnMac else { return }
23
+ NSLog("MacQuit: skipping static destructors on exit")
24
+ atexit {
25
+ fflush(nil)
26
+ _exit(0)
27
+ }
28
+ }
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/crust",
3
- "version": "3.5.0-dev.1367",
3
+ "version": "3.5.0-dev.1372",
4
4
  "description": "Mentra Native Module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "license": "Apache-2.0",
36
36
  "homepage": "https://github.com/Mentra-Community/MentraOS/tree/dev/mobile/modules/crust#readme",
37
37
  "dependencies": {
38
- "@mentra/jspolyfill": "3.5.0-dev.1367"
38
+ "@mentra/jspolyfill": "3.5.0-dev.1372"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@expo/config-plugins": ">=8.0.0",