flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [crashlytics][release] Sending log using `DiagnosticsNode.message` shows up as `'Instance of 'DiagnosticsProperty<void>'`

Open mirrorlink opened this issue 3 years ago • 7 comments

Bug report

It seems that when I try to send logs and the app is in release mode, the logs show as 'Instance of 'DiagnosticsProperty<void>' instead of the actual logs.

Steps to reproduce

Log the following

FirebaseCrashlytics.instance.recordError(Exception('test A'), null,
    reason: 'test B',
    fatal: false,
    information: [
      DiagnosticsNode.message('test C'),
      DiagnosticsNode.message('test D'),
    ]);

Expected behavior

"test C" and "test D" strings to show up properly on crashlytics in firebase console when app is on release instead of 'Instance of 'DiagnosticsProperty<void>'


On debug:

image

on Release:

image

mirrorlink avatar Jan 20 '22 21:01 mirrorlink

It seems that the diagnostics.dart file has a lot of disabled stuff on release.

image

am I taking crazy pills here? haha it seems I am the only one with this issue

shouldnt recordError use its own logging class or maybe just a simple string arrray instead of diagnosticsNode ?

mirrorlink avatar Jan 20 '22 22:01 mirrorlink

@mirrorlink Can you provide flutter doctor -v along with the platform on which you are seeing this (Android or iOS or on both) ?

darshankawar avatar Jan 21 '22 11:01 darshankawar

@mirrorlink Can you provide flutter doctor -v along with the platform on which you are seeing this (Android or iOS or on both) ?

Hey @darshankawar

here it is:

[√] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 10.0.19043.1466], locale en-US)
    • Flutter version 2.8.0 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cf44000065 (6 weeks ago), 2021-12-08 14:06:50 -0800
    • Engine revision 40a99c5951
    • Dart version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\mirrorlink\AppData\Local\Android\Sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = C:\Users\mirrorlink\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio3\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio3
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[!] Android Studio (version 4.1)
    • Android Studio at C:\Program Files\Android\Android Studio2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] VS Code, 64-bit edition (version 1.63.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.32.0

[√] Connected device (3 available)
    • moto g 7 play (mobile) • 0053761073 • android-arm    • Android 10 (API 29)
    • Chrome (web)           • chrome     • web-javascript • Google Chrome 97.0.4692.99
    • Edge (web)             • edge       • web-javascript • Microsoft Edge 95.0.1020.53

! Doctor found issues in 1 category.

I'm testing everything on Android.

mirrorlink avatar Jan 21 '22 12:01 mirrorlink

Thanks for the update. With the plugin example and using log code snippet as below in release mode on latest master (Channel master, 2.9.0-1.0.pre.491):

FirebaseCrashlytics.instance.recordError(Exception('test A'), null,
    reason: 'test B',
    fatal: false,
    information: [
      DiagnosticsNode.message('test C'),
      DiagnosticsNode.message('test D'),
    ]);

I get 'Instance of 'DiagnosticsProperty<void>'. Maybe in release mode, the code is being obfuscated and hence this behavior ? Keeping this open for further investigation from team.

/cc @russellwheatley

darshankawar avatar Jan 25 '22 09:01 darshankawar

yeah @darshankawar

take a look: image

i dont think diagnostics.dart is meant to be used in release mode. its not that the code is obfuscated, I think that the "toString" method of the class is not overwritten properly on release and it defaults to the default behaviour of printing an object, that is "instance of blablabla".

mirrorlink avatar Jan 25 '22 10:01 mirrorlink

Yeah, it's not meant to be used for release, apparently. According to the documentation of DiagnosticsNode (the superclass of DiagnosticsProperty<T>):

/// In release mode, far less information is retained and some information may /// not print at all.

So now I'm wondering: What, if any, is the idiomatic way to log helpful data in the event of an exception in release?

livtanong avatar Feb 21 '22 03:02 livtanong

Any update? I encountered the same issue.

623637646 avatar Sep 21 '22 13:09 623637646

We have a PR for this now. Should fix the problem 👍

russellwheatley avatar Oct 05 '22 10:10 russellwheatley