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

SentryNativeChannel.captureReplay Error: type 'Null' is not a subtype of type 'String' in type cast on iOS only #2568

Closed
kenil-gorin opened this issue Jan 10, 2025 · 12 comments

Comments

@kenil-gorin
Copy link

Platform

Flutter Mobile iOS

Obfuscation

Enabled

Debug Info

Enabled

Doctor

[✓] Flutter (Channel stable, 3.24.5, on macOS 13.6.1 22G313 darwin-x64, locale
en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.96.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Version

8.12.0

Steps to Reproduce

  1. Setup the Sentry Session Replay by adding:
      options.experimental.replay.sessionSampleRate = 1.0;
      options.experimental.replay.onErrorSampleRate = 1.0;
      options.screenshotQuality = SentryScreenshotQuality.low;
      options.reportSilentFlutterErrors = true;
      options.attachScreenshot = true;
      options.attachViewHierarchy = true;
      options.experimental.privacy.maskAssetImages = false;
      options.experimental.privacy.maskAllText = false;
      options.experimental.privacy.maskAllImages = false;
      options.debug = true;
      options.diagnosticLevel = SentryLevel.debug;
  1. Run the app on the iOS Simulator.

  2. Get the following issue and Session replay has been not recorded:

[sentry] [error] An exception occurred while processing event by a processor
[sentry] _TypeError (type 'Null' is not a subtype of type 'String' in type cast)
[sentry] #0      SentryNativeChannel.captureReplay.<anonymous closure> (package:sentry_flutter/src/native/sentry_native_channel.dart:236:48)
         <asynchronous suspension>
         #1      ReplayEventProcessor.apply (package:sentry_flutter/src/event_processor/replay_event_processor.dart:19:24)
replay_event_processor.dart:19
         <asynchronous suspension>
         #2      SentryClient._runEventProcessors (package:sentry/src/sentry_client.dart:590:28)
sentry_client.dart:590
         <asynchronous suspension>
         #3      SentryClient.captureEvent (package:sentry/src/sentry_client.dart:147:21)
sentry_client.dart:147
         <asynchronous suspension>
         #4      Hub.captureEvent (package:sentry/src/hub.dart:116:20)
hub.dart:116
         <asynchronous suspension>
         #5      DefaultTaskQueue.enqueue (package:sentry/src/transport/task_queue.dart:43:16)
task_queue.dart:43
         <asynchronous suspension>

This setup for session replay is perfectly working on Android, and I can see the capture session on the Sentry Dashboard, While running on the iOS simulator, it's giving an error and not capturing the session.

Expected Result

Session Replay should capture user sessions and display them in the Sentry Dashboard.

Actual Result

When running the app on the iOS Simulator, the session replay is not recorded, and the following error occurs:

[sentry] [error] An exception occurred while processing event by a processor
[sentry] _TypeError (type 'Null' is not a subtype of type 'String' in type cast)
[sentry] #0      SentryNativeChannel.captureReplay.<anonymous closure> (package:sentry_flutter/src/native/sentry_native_channel.dart:236:48)
         <asynchronous suspension>
         #1      ReplayEventProcessor.apply (package:sentry_flutter/src/event_processor/replay_event_processor.dart:19:24)
replay_event_processor.dart:19
         <asynchronous suspension>
         #2      SentryClient._runEventProcessors (package:sentry/src/sentry_client.dart:590:28)
sentry_client.dart:590
         <asynchronous suspension>
         #3      SentryClient.captureEvent (package:sentry/src/sentry_client.dart:147:21)
sentry_client.dart:147
         <asynchronous suspension>
         #4      Hub.captureEvent (package:sentry/src/hub.dart:116:20)
hub.dart:116
         <asynchronous suspension>
         #5      DefaultTaskQueue.enqueue (package:sentry/src/transport/task_queue.dart:43:16)
task_queue.dart:43
         <asynchronous suspension>

Are you willing to submit a PR?

None

@vaind
Copy link
Collaborator

vaind commented Jan 10, 2025

Thanks for reporting this.

When running the app on the iOS Simulator, the session replay is not recorded, and the following error occurs:

Can you please share logs before this error?

@kenil-gorin
Copy link
Author

Launching lib/main_dev.dart on iPhone 13 Pro Max in debug mode...
Xcode build done.                                           71.5s
Connecting to VM Service at ws://127.0.0.1:50344/B05MTooax2s=/ws
Connected to the VM Service.
flutter: Remote config fetched and activated: true
flutter: The config has been updated.
W/Swift: [AWESOME NOTIFICATIONS] WARNING: The current licenses for Awesome Notifications does not cover this FCM plugin release. Please update your license to use the latest version of Awesome Notification's FCM plugin in release mode without watermarks. Application ID: "com.cursorblue.cc-pushka.dev". Version: 0.10.0. For more information and to update your license, please visit https://awesome-notifications.carda.me#prices. (LicenseManager:121)
[sentry] [debug] FramesTrackingIntegration successfully initialized with an expected frame duration of 16ms
[sentry] [debug] release: [email protected]+2
flutter: AppUpdateService getAppUpdate
flutter:
flutter: --- Branch Data Structure ---
flutter: +clicked_branch_link: false
flutter: +is_first_session: false
flutter: -------------------------
[sentry] [error] An exception occurred while processing event by a processor
[sentry] _TypeError (type 'Null' is not a subtype of type 'String' in type cast)
[sentry] #0      SentryNativeChannel.captureReplay.<anonymous closure> (package:sentry_flutter/src/native/sentry_native_channel.dart:236:48)
         <asynchronous suspension>
         #1      ReplayEventProcessor.apply (package:sentry_flutter/src/event_processor/replay_event_processor.dart:19:24)
replay_event_processor.dart:19
         <asynchronous suspension>
         #2      SentryClient._runEventProcessors (package:sentry/src/sentry_client.dart:590:28)
sentry_client.dart:590
         <asynchronous suspension>
         #3      SentryClient.captureEvent (package:sentry/src/sentry_client.dart:147:21)
sentry_client.dart:147
         <asynchronous suspension>
         #4      Hub.captureEvent (package:sentry/src/hub.dart:116:20)
hub.dart:116
         <asynchronous suspension>
         #5      DefaultTaskQueue.enqueue (package:sentry/src/transport/task_queue.dart:43:16)
task_queue.dart:43
         <asynchronous suspension>

Let me know if it's enough or not.

@vaind
Copy link
Collaborator

vaind commented Jan 13, 2025

I couldn't reproduce the issue and given logs don't indicate what could lead to it. Is this something that always happens in your app? Do Android replays work fine? Could you maybe create a small repro example app that shows this issue? Alternatively you could also try running agains latest unreleased version of the sentry-dart SDK by specifying it as a git dependency https://dart.dev/tools/pub/dependencies#git-packages although I'm not aware of any recent changes that would affect the described behavior.

@getsantry getsantry bot moved this from Waiting for: Product Owner to Waiting for: Community in GitHub Issues with 👀 3 Jan 13, 2025
@kenil-gorin
Copy link
Author

Android replay always works fine, Whenever I run the iOS app, it always gives the error. I've to do it in xcodeproject, info.plist, or AppDelegate.swift related changed? Like any native specific confirmations I've to perform?

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 13, 2025
@vaind
Copy link
Collaborator

vaind commented Jan 13, 2025

Whenever I run the iOS app, it always gives the error.

The error coming from the event processor happens when a replay is being attached to another error. It may help if we could figure out what error is being handled by the event processor - maybe the whole issue is about the lifecycle and replay is somehow not initialized at the time that error occurs.

I've to do it in xcodeproject, info.plist, or AppDelegate.swift related changed? Like any native specific confirmations I've to perform?

Note sure I understand - are you asking about the suggestion to use the latest main as a package dependency? If so, you can do it by updating pubspec.yaml and changing your dependency on sentry_flutter to:

dependencies:
  sentry_flutter:
    git:
      url: https://github.com/getsentry/sentry-dart.git
      ref: ec50b2159d85b69bbbb3619960b3f922ec5592f5
      path: flutter

@kenil-gorin
Copy link
Author

@vaind

Please let me know one thing, I'm trying session replay on the simulator. So it can run the session replay on Simulator, right?

Or I've to run on the real iOS device?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 14, 2025
@vaind
Copy link
Collaborator

vaind commented Jan 14, 2025

@vaind

Please let me know one thing, I'm trying session replay on the simulator. So it can run the session replay on Simulator, right?

Simulator is fine.

@kenil-gorin
Copy link
Author

I'm trying on the simulator, whenever there is an error, the event is always height dropped by the processor. Please look at the below error log.

[sentry.platformError] [error] Uncaught Platform Error
[sentry.platformError] PlatformException (PlatformException(INSUFFICIENT_PERMISSIONS, Notifications are disabled, insufficientPermissions.global, null))
[sentry.platformError] #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
                       #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
platform_channel.dart:334
                       <asynchronous suspension>
                       #2      MethodChannelAwesomeNotifications.createNotification (package:awesome_notifications/awesome_notifications_method_channel.dart:102:29)
awesome_notifications_method_channel.dart:102
                       <asynchronous suspension>
                       #3      NotificationService.scheduleAllNotifications (package:pushkah/services/notifications_service.dart:216:13)
notifications_service.dart:216
                       <asynchronous suspension>
[log] didChangeAppLifecycleState: AppLifecycleState.inactive
[sentry] [info] Duplicated exception detected. Event fc422bf7189c470897dfe7483e655819 will be discarded.
[sentry] [debug] Event was dropped by a processor
[sentry] [error] An exception occurred while processing event by a processor
[sentry] _TypeError (type 'Null' is not a subtype of type 'String' in type cast)
[sentry] #0      SentryNativeChannel.captureReplay.<anonymous closure> (package:sentry_flutter/src/native/sentry_native_channel.dart:236:48)
         <asynchronous suspension>
         #1      ReplayEventProcessor.apply (package:sentry_flutter/src/event_processor/replay_event_processor.dart:19:24)
replay_event_processor.dart:19
         <asynchronous suspension>
         #2      SentryClient._runEventProcessors (package:sentry/src/sentry_client.dart:590:28)
sentry_client.dart:590
         <asynchronous suspension>
         #3      SentryClient.captureEvent (package:sentry/src/sentry_client.dart:147:21)
sentry_client.dart:147
         <asynchronous suspension>
         #4      Hub.captureException (package:sentry/src/hub.dart:178:20)
hub.dart:178
         <asynchronous suspension>
         #5      DefaultTaskQueue.enqueue (package:sentry/src/transport/task_queue.dart:43:16)
task_queue.dart:43
         <asynchronous suspension>
[sentry] [debug] WidgetFilter skipping invisible: Opacity(opacity: 0.0)
[log] didChangeAppLifecycleState: AppLifecycleState.resumed

And if there is no error, then it does not even capture any session replay. So Here I'm stuck on what to do, I've tried using the direct git repo as a dependency but getting the same issue, replays are not captruring.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 14, 2025
@vaind
Copy link
Collaborator

vaind commented Jan 14, 2025

Just to clarify - your app is a flutter app, not native with flutter integrated?

How are you launching the app? The log you've linked above doesn't actually show any sentry-flutter SDK debug messages.

@kenil-gorin
Copy link
Author

@vaind Apologies for the inconvenience.

I discovered the issue: Session Replay does not work on iOS versions below 16, and I was testing on iOS 15, which is why the session replay wasn’t captured. After testing on iOS 17, it’s working perfectly.

Thank you so much for your valuable assistance and support throughout. I truly appreciate it!

@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Jan 15, 2025
@vaind
Copy link
Collaborator

vaind commented Jan 15, 2025

Thanks, we'll clarify in the docs and handle in the flutter code

@vaind vaind added the docs label Jan 15, 2025
@vaind vaind self-assigned this Jan 15, 2025
@vaind vaind reopened this Jan 15, 2025
@buenaflor buenaflor moved this from Done to Backlog in Mobile & Cross Platform SDK Jan 16, 2025
@vaind
Copy link
Collaborator

vaind commented Jan 17, 2025

The lowest iOS simulator version I was able to install that still works with my version of mac was iOS 15.2 and that still seems to work fine - captured a replay in the example app and linked to an error:

Image

Since I cannot verify and the user has resolved the issue on their end too, I'm closing this again. Let's follow up if there're new findings in the future.

@vaind vaind closed this as completed Jan 17, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Mobile & Cross Platform SDK Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Status: Done
Development

No branches or pull requests

2 participants