Skip to content

App performance greatly reduced by captureConsoleIntegration #3992

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

Open
4 of 11 tasks
yefim opened this issue Aug 5, 2024 · 5 comments · May be fixed by #4770
Open
4 of 11 tasks

App performance greatly reduced by captureConsoleIntegration #3992

yefim opened this issue Aug 5, 2024 · 5 comments · May be fixed by #4770
Assignees

Comments

@yefim
Copy link

yefim commented Aug 5, 2024

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 5.26.0

react-native version: 0.74.6

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

Configuration:

(@sentry/react-native)

  Sentry.init({
    dsn: process.env.EXPO_PUBLIC_SENTRY_DSN,
    enableInExpoDevelopment: false,
    enabled: !IS_DEV_BUILD,
    debug: IS_DEV_BUILD,
    environment: `app:${APP_ENV}`,
    integrations: [captureConsoleIntegration({ levels: ['error', 'assert'] })],
    ignoreErrors: [
      'Amplitude Logger [Error]',
      'ViewPropTypes will be removed from React Native',
      'POP_TO_TOP',
    ],
  });


I have the following issue:

After upgrading @sentry/integrations from "7.81.1" to "7.114.0" we noticed a large performance regression. The app was taking a long time to respond to a user's tap.

Before (@sentry/integrations 7.81.1)

RPReplay_Final1721856524.MP4

After (@sentry/integrations 7.114.0)

RPReplay_Final1721856599.MP4

When we enabled Sentry in dev, we saw a bunch of logs that were clogging up the console and were able to reproduce the unresponsiveness locally. I've uploaded a video at #3963 (comment)

Steps to reproduce:

  • Enable captureConsoleIntegration integration
  • Try navigating around the app

Actual result:

App is slow to respond to user's tap.

Expected result:

App navigates as normal

@kahest
Copy link
Member

kahest commented Aug 6, 2024

@yefim thank you for the detailed report and the videos, we appreciate the effort. Do you know if this also occurs on Android, or only on iOS?

@yefim
Copy link
Author

yefim commented Aug 6, 2024

Yes, seeing the same against Android in development.

android-dev-slow.mp4

Here's the code diff:

Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Aug 6, 2024
@getsantry getsantry bot removed the status in GitHub Issues with 👀 3 Aug 6, 2024
@krystofwoldrich krystofwoldrich changed the title App performance greatly reduced by captureConsoleIntegration on iOS App performance greatly reduced by captureConsoleIntegration Aug 9, 2024
@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Needs Investigation in [DEPRECATED] Mobile SDKs Aug 9, 2024
@krystofwoldrich
Copy link
Member

@yefim Thank you for the details, we will investigate it.

@lucas-zimerman
Copy link
Collaborator

lucas-zimerman commented Aug 16, 2024

It can be reproduced on the React Native sample by using the following init:

Sentry.init({
  // Replace the example DSN below with your own DSN:
  dsn: SENTRY_INTERNAL_DSN,
  debug: true,
  environment: 'dev',
  integrations(integrations) {
    integrations.push(
      captureConsoleIntegration({ levels: ['error', 'assert'] }),
    );
    return integrations;

  },
});

It seems like when we add the level 'assert' all this block appears, I noticed that there are loads of symbolication calls when this happens and navigation is surely almost impossible todo on the app. On the JavaScript debug log things seems calm but on logcat there is a nonstop calls to symbolicate

EDIT: I replaced the assert callback and this is the message + stacktrace from where it was being called.

 LOG  Assertion called: true  message 'this' is expected an Event object, but got [{"isTrusted":false}] stack : Error
    at getCurrentStackTrace (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:125938:26)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:125950:57)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:154465:27)
    at pd (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36235:19)
    at setPassiveListener (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36640:7)
    at dispatchEvent (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36939:27)
    at setReadyState (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36129:27)
    at open (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:36041:27)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:155583:34)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:29261:17)
    at tryCallTwo (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204678:9)
    at doResolve (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204817:25)
    at Promise (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204697:14)
    at fetch (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:29218:25)
    at ?anon_0_ (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28649:33)
    at next (native)
    at asyncGeneratorStep (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28665:26)
    at _next (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28684:29)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28689:14)
    at tryCallTwo (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204678:9)
    at doResolve (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204817:25)
    at Promise (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:204697:14)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28681:25)
    at apply (native)
    at _symbolicateStackTrace (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28658:40)
    at apply (native)
    at symbolicateStackTrace (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28637:40)
    at symbolicate (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28616:52)
    at handleSymbolicate (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28516:42)
    at symbolicate (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28507:33)
    at appendNewLog (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28152:25)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:28196:21)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35288:26)
    at _callTimer (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35167:17)
    at _callReactNativeMicrotasksPass (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35212:17)
    at callReactNativeMicrotasks (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:35418:44)
    at __callReactNativeMicrotasks (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3569:48)
    at anonymous (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3342:45)
    at __guard (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3541:15)
    at flushedQueue (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3341:21)
    at callFunctionReturnFlushedQueue (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=io.sentry.reactnative.sample&modulesOnly=false&runModule=true:3326:33)

https://sentry-sdks.sentry.io/issues/5718158513

@lucas-zimerman lucas-zimerman moved this from Needs Investigation to Backlog in [DEPRECATED] Mobile SDKs Aug 16, 2024
@lucas-zimerman lucas-zimerman removed their assignment Aug 16, 2024
@lucas-zimerman lucas-zimerman moved this from Backlog to Needs Discussion in [DEPRECATED] Mobile SDKs Aug 16, 2024
@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Backlog in [DEPRECATED] Mobile SDKs Aug 16, 2024
@lucas-zimerman lucas-zimerman moved this from Backlog to In Progress in [DEPRECATED] Mobile SDKs Mar 17, 2025
@lucas-zimerman
Copy link
Collaborator

lucas-zimerman commented Mar 18, 2025

I am stil looking at it, but in the meantime I have an update that this issue is no longer happening on @sentry/react-native version 6.0.0 or newer.
The fix was implemented here: https://github.com/getsentry/sentry-javascript/pull/11799/files#diff-54a4bb3b994992c0392eba31977780bac7892c266a8b0998ca213331a1eb57adR67

EDIT: It seems like the issue lies on this library used by React Native: https://gitlab.cin.ufpe.br/vrs2/iot-trafficlight-final/-/blob/main/node_modules/event-target-shim/dist/event-target-shim.mjs?ref_type=heads#L42-44

The symbolication code uses a fetch code that relies on this library, and with that it creates those assert messages, and since we are creating events with the fetched event, we will end up on a loop.

We ignore those events on the integration but it would be nice to shield it better against such issues in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Needs Review
Development

Successfully merging a pull request may close this issue.

5 participants