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

Crash on watchOS #22

Open
fnazarios opened this issue Jan 8, 2025 · 9 comments
Open

Crash on watchOS #22

fnazarios opened this issue Jan 8, 2025 · 9 comments

Comments

@fnazarios
Copy link
Contributor

We've seen a trend of a crash happening on the watchOS. All information we have is the screenshot bellow from Xcode's Organizer as annoyingly the watchOS does not have the same Crash Report as iOS.
Screenshot 2025-01-08 at 17 14 35

@daniel-statsig
Copy link
Contributor

Hey @fnazarios, sorry this is happening. Can you provide a little more context?

  • Which version are you running?
  • Is this something that started with a recent update?

@fnazarios
Copy link
Contributor Author

fnazarios commented Jan 8, 2025

Hey @daniel-statsig.

  • This is happening with 1.47.0
  • Kinda hard to tell exactly when it started because the watchOS crash log is very rudimentary. But it looks like it started to happen when we updated to 1.47.0

FYI I just opened a PR updating to 1.49.0

@andre-statsig
Copy link
Contributor

Hi @fnazarios, looks like due to a refactor, we removed a try/catch block surrounding the initialization on 1.47.0. I assume this error was happening before 1.47.0, but wasn't triggering a crash. I'll try to add a try/catch block back in to prevent crashes. But keep in mind if the same error happens, those sessions will likely not have access to Statsig's features.

To help fix the underlying issue, I have a couple questions:

  1. Is that CodableStorage a class in your codebase?
  2. How are you calling Statsig.start? What parameters and options are you passing to it?

@andre-statsig
Copy link
Contributor

Another question:
3. Does the exception being thrown have a name?

@fnazarios
Copy link
Contributor Author

fnazarios commented Jan 8, 2025

All the information we have is this log from the Xcode Organizer. Crash analysis for the watchOS app is a nightmare.

  1. Yes, CodableStorage is on our codebase but not used in any sense on this scope
  2. That's my Statsig.start:
Statsig.start(
	sdkKey: kStatsigClientKey,
	user: StatsigUser(userID: userId),
	options: StatsigOptions(
		initTimeout: 120,
		environment: environment(kStatsigEnvironment)
	)
) { errorMessage in
	if let errorMessage {
		printLog(message: "🎛️ Statsig initialization: \(errorMessage)")
		return
	}

	printLog(message: "🎛️ Statsig initialization completed")
}
  1. I never manage to reproduce this crash, but many users have and all the information I have is on that screenshot

@andre-statsig
Copy link
Contributor

My suggestion is to roll back to 1.46.0 for now. This should hopefully mitigate the crashes your users are seeing.

As for the underlying error, I'm unsure how the thread goes from StatsigClient.init(...) to CodableStorage.__deallocating_deinit. But my interpretation is that a deallocation is triggering the crash.

Does the CodableStorage class have a deinit function?

I wonder if the Memory Debugging Tools would surface anything on your app. I couldn't reproducing the crash on a sample app yet, but here's how I enabled some of their Memory Management tools:

I edited the run scheme...

Screenshot 2025-01-09 at 1 43 25 PM

...and enabled all Memory Management checkboxes on the Diagnostics tab

Screenshot 2025-01-09 at 1 43 13 PM

Let us know if you learn more about the crash, or if 1.46.0 mitigates it.

@fnazarios
Copy link
Contributor Author

FYI. The CodableStorage didn't have a deinit. I removed this class from the codebase. It was not being used anywhere.

@fnazarios
Copy link
Contributor Author

fnazarios commented Jan 10, 2025

About downgrading to 1.46.0. I initially updated to 1.47.0 due to a build failure on 1.46.0 regarding StatsigInternalObjC. So, I guess downgrading now will end up with the same behavior. Am correct?

@andre-statsig
Copy link
Contributor

FYI. The CodableStorage didn't have a deinit. I removed this class from the codebase. It was not being used anywhere.

Thanks for letting me know!

About downgrading to 1.46.0. I initially updated to 1.47.0 due to a build failure on 1.46.0 regarding StatsigInternalObjC. So, I guess downgrading now will end up with the same behavior. Am correct?

Yeah, most likely.

For the crash, we'll try to reproduce it with a physical Apple Watch to see if we can get more information. Keep us updated if you learn more about it.

As for the mitigation, Swift's do/try/catch doesn't handle runtime exceptions unfortunately. So if we want a "catch-all" mitigation, we need an Objective-C layer. This was the purpose of StatsigInternalObjC and the ErrorBoundary. We can look into adding ErrorBoundary back in if we can prevent the build failures. You could try to add a similar Objective-C wrapper around the Statsig initializer to see if that mitigates the crashes.

Thanks again for reporting this and helping debug this crash. Apologies for not having more information about it.

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

No branches or pull requests

3 participants