Skip to content

Call to native function crashes the application with no exception or error log #7517

@dgellow

Description

@dgellow

Environment

Run the following in your terminal and copy the results here.

  1. npx react-native --version: 5.0.1-alpha.2
  2. npx react-native info:
info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.21343
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 7.38 GB / 15.92 GB
  Binaries:
    Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.18362.0, 10.0.19041.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 16.9.31129.286 (Visual Studio Community 2019)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.0 => 0.64.0
    react-native-windows: ^0.64.0-0 => 0.64.2
  npmGlobalPackages:
    *react-native*: Not Found

Some Context

I'm experimenting with Native Modules and implemented a simple function that plays a sound by calling Windows.UI.Xaml.ElementSoundPlayer.Play().

You can see the complete project here: https://github.com/dgellow/rnw-crash-sample-1.

The module SoundPlayer is made of the C++ header, the C++ implementation, and the TypeScript wrapper.

Other calls to native modules work without problem (I used the FancyMath example from the documentation as an example of working native module).

Steps To Reproduce

  1. git clone https://github.com/dgellow/rnw-crash-sample-1.git
  2. cd rnw-crash-sample-1
  3. yarn install
  4. yarn windows
  5. after the application started, click on a "play sound" button (see gif screencast below)
  6. notice how the application crashes without stack trace or error log (it just exits directly)

Expected Results

I expected sound to be played. And in the case where something is wrong I expected an exception to be raised and displayed in the red LogBox, or an error log either in the attached browser or in metro.

Snack, code example, screenshot, or link to a repository:

recording

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions