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

[🐛] getInitialNotification - Map already consumed #5231

Closed
3 of 10 tasks
xxsnakerxx opened this issue Apr 29, 2021 · 8 comments · Fixed by #5236
Closed
3 of 10 tasks

[🐛] getInitialNotification - Map already consumed #5231

xxsnakerxx opened this issue Apr 29, 2021 · 8 comments · Fixed by #5236
Labels
impact: crash Behaviour causing app to crash. platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications type: bug New bug report Workflow: Needs Review Pending feedback or review from a maintainer.

Comments

@xxsnakerxx
Copy link

Issue

com.facebook.react.bridge.ObjectAlreadyConsumedException: Map already consumed
        at com.facebook.react.bridge.WritableNativeArray.pushNativeMap(WritableNativeArray.java:-2)
        at com.facebook.react.bridge.WritableNativeArray.pushMap(WritableNativeArray.java:2)
        at com.facebook.react.bridge.Arguments.fromJavaArgs(Arguments.java:17)
        at com.facebook.react.bridge.CallbackImpl.invoke(CallbackImpl.java:2)
        at com.facebook.react.bridge.PromiseImpl.resolve(PromiseImpl.java:2)
        at io.invertase.firebase.messaging.ReactNativeFirebaseMessagingModule.getInitialNotification(ReactNativeFirebaseMessagingModule.java:2)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:14)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:2)
        at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java:-2)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:1)
        at android.os.Looper.loop(Looper.java:164)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:11)
        at java.lang.Thread.run(Thread.java:764)

Project Files

Javascript

Click To Expand

package.json:

"@react-native-firebase/analytics": "11.3.3",
"@react-native-firebase/app": "11.3.3",
"@react-native-firebase/messaging": "11.3.3",

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
install! 'cocoapods', :deterministic_uuids => false
platform :ios, '12.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

project 'yourcoach',
  'Debug' => :debug,
  'DevStaging' => :release,
  'Staging' => :release,
  'Rc' => :release,
  'Release' => :release

$RNFirebaseAsStaticFramework = true

target 'project' do
  use_frameworks!

  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  # react-native-permissions
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"

  # Convert pods into static libraries
  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
        def pod.build_type;
          Pod::BuildType.static_library # >= 1.9
        end
      end
      if pod.name.eql?('RNScreens')
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end

  pod 'OpenTok', '2.18.1'
  pod 'ShowTime'

  target 'projectTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(installer)

    # https://github.com/facebook/react-native/issues/31149
    installer.pods_project.targets.each do |target|
      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
  end
end

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
    Memory: 33.21 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.1 - /var/folders/st/6l5nbbf10hzc7kj3gw1w7cfw0000gn/T/yarn--1619681061128-0.496517025922973/node
    Yarn: 1.22.10 - /var/folders/st/6l5nbbf10hzc7kj3gw1w7cfw0000gn/T/yarn--1619681061128-0.496517025922973/yarn
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/username/.rvm/gems/ruby-2.6.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 29, 30
      Build Tools: 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7199119
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.64.0 => 0.64.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • e.g. 5.4.3
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N & VERSION


@xxsnakerxx xxsnakerxx added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Apr 29, 2021
@mikehardy
Copy link
Collaborator

Hmmm that stack trace is from a release build and looks obfuscated. Any chance you can decode it or post a dev stack or an app.js that is self contained and steps to reproduce? The faster I can reproduce it the faster I can fix it

@mikehardy mikehardy added impact: crash Behaviour causing app to crash. platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Workflow: Needs Review Pending feedback or review from a maintainer. Workflow: Waiting for User Response Blocked waiting for user response. labels Apr 29, 2021
@xxsnakerxx
Copy link
Author

I can't reproduce it in the dev environment, but I had received the error from a user on the production. And all I know is it happens on android 8.1 ( Motorola Moto G(5S) ). I have a device with Android 11, and I can't reproduce the error.

UPD

I have feedback from the user. He taps on a notification(on the lock screen) while the app in the background.

The getInitialNotification call is in one place in the app.

App.tsx

componentDidMount() {
...
    try {
      const notification = await firebase.messaging().getInitialNotification();

      if (notification) {
        setTimeout(() => {
          this._onReceivePushNotification(notification.data);
        }, 1000);
      }
    } catch (error) {
      logger.error(error);
    }

    firebase.messaging().onNotificationOpenedApp(({data}) => {
      this._onReceivePushNotification(data);
    });
...
}

I hope it could help.

@mikehardy
Copy link
Collaborator

I see the problem - related to recent PR #5181 for issue #4943 specifically the same message map object may be used twice now:

https://github.com/invertase/react-native-firebase/pull/5181/files#diff-945d05be567b9871eff943790a8b6ff7efde8bcd48a0b41d24d240b4687859c0R63

and

https://github.com/invertase/react-native-firebase/pull/5181/files#diff-945d05be567b9871eff943790a8b6ff7efde8bcd48a0b41d24d240b4687859c0R87

I'll make it so the second one is a copy, which should make the JSI bridge happier with the object as it will be fresh / un-consumed the second time

@mikehardy mikehardy removed Workflow: Waiting for User Response Blocked waiting for user response. help: needs-triage Issue needs additional investigation/triaging. labels Apr 29, 2021
@mikehardy
Copy link
Collaborator

Release 11.4.1 just went out with the change related to this among other fixes + features. Enjoy! 🚀

@inmogr
Copy link

inmogr commented Oct 26, 2021

issue still persist in version @react-native-firebase/dynamic-links@12.7.2 error message ObjectAlreadyConsumedException: Map already consumed

Screen Shot 2021-10-27 at 2 10 31 AM

n

@inmogr
Copy link

inmogr commented Oct 26, 2021

@mikehardy kindly reopen this ticket

@mikehardy
Copy link
Collaborator

@inmogr I believe this is a duplicate of the similar but different new #5812 which should be fixed by #5814

Your feedback testing the related patch is requested: #5812 (comment)

Should be released in a day or two but feedback would be great.

@inmogr
Copy link

inmogr commented Oct 26, 2021

@mikehardy will test the patch thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: crash Behaviour causing app to crash. platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications type: bug New bug report Workflow: Needs Review Pending feedback or review from a maintainer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants