Skip to content

Commit c36abd5

Browse files
philprimejas-kas
andauthored
feat(apple): Add session replay trouble shooting page with custom window handling (#13753)
## DESCRIBE YOUR PR During debugging of the SDK we discovered that session replay for iOS requires on the `window` property of the window scene delegate / `UIWindowSceneDelegate` to be set. By default this will be set during the bootstrapping of the app, but it appears that the property can also be omitted and not configured. This PR adds documentation to indicate to users how to deal with this. It's also the start of having a troubleshooting section dedicated to session replay: https://sentry-docs-git-philprime-session-replay-scene-delegate.sentry.dev/platforms/apple/guides/ios/session-replay/troubleshooting/ ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [X] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [X] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Apple Documentation](https://developer.apple.com/documentation/uikit/uiwindowscenedelegate/window) --------- Co-authored-by: Jasmin <[email protected]>
1 parent d60f74b commit c36abd5

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

docs/platforms/apple/common/troubleshooting/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,7 @@ To resolve this problem try the following:
226226
4. Restart Xcode
227227
5. Reset your package cache if using Swift Package Manager by going to **File > Packages > Reset Package Caches**
228228
6. Rebuild your project
229+
230+
## Troubleshooting Session Replay
231+
232+
See [Session Replay - Troubleshooting](/platforms/apple/guides/ios/session-replay/troubleshooting) for more information.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Troubleshooting
3+
sidebar_order: 5503
4+
notSupported:
5+
description: "Troubleshoot and resolve common issues with the iOS Session Replay."
6+
---
7+
8+
## Session Replay is not recording with custom window setup
9+
10+
If you have a custom window setup (e.g., multiple instances of `UIWindow`), you need to ensure that the Sentry SDK is able to find the correct window.
11+
12+
When using window scenes, make sure that the main window is assigned in your `UIWindowSceneDelegate`'s [`window` property](https://developer.apple.com/documentation/uikit/uiwindowscenedelegate/window).
13+
14+
```swift
15+
final class SceneDelegate: NSObject, UIWindowSceneDelegate {
16+
17+
var window: UIWindow?
18+
19+
func scene(
20+
_ scene: UIScene,
21+
willConnectTo session: UISceneSession,
22+
options connectionOptions: UIScene.ConnectionOptions
23+
) {
24+
guard let scene = scene as? UIWindowScene else { return }
25+
26+
// Configure your windows here, e.g.
27+
let mainWindow = UIWindow(windowScene: scene)
28+
mainWindow.rootViewController = UIViewController()
29+
mainWindow.makeKeyAndVisible()
30+
31+
// Do not forget to assign the window to the SceneDelegate's window property:
32+
self.window = mainWindow
33+
}
34+
}
35+
```
36+
37+
Alternatively, you can also create a custom proxy variable for the window:
38+
39+
```swift
40+
final class SceneDelegate: NSObject, UIWindowSceneDelegate {
41+
42+
var mainWindow: UIWindow?
43+
44+
func scene(
45+
_ scene: UIScene,
46+
willConnectTo session: UISceneSession,
47+
options connectionOptions: UIScene.ConnectionOptions
48+
) {
49+
guard let scene = scene as? UIWindowScene else { return }
50+
51+
// Configure your windows here, e.g.
52+
let mainWindow = UIWindow(windowScene: scene)
53+
mainWindow.rootViewController = UIViewController()
54+
mainWindow.makeKeyAndVisible()
55+
56+
// Do not forget to assign the window to the SceneDelegate's window property:
57+
self.window = mainWindow
58+
}
59+
60+
// This is required to make sure that the Sentry SDK can find the correct window:
61+
62+
var window: UIWindow? {
63+
get {
64+
return mainWindow
65+
}
66+
set {
67+
mainWindow = newValue
68+
}
69+
}
70+
}
71+
```

0 commit comments

Comments
 (0)