microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.4k stars 1.14k forks source link

Binary dependencies of native modules are not included for C++ apps when deploying via `run-windows` #5639

Closed jonthysell closed 4 years ago

jonthysell commented 4 years ago

Summary

I'm writing a test app which tests https://github.com/react-native-community/react-native-camera/pull/2930, which adds barcode scanning to react-native-camera.

Barcode scanning is provided by a third-party winrt binary (ZXing.winrt, ZXing.dll) via nuget: https://www.nuget.org/packages/huycn.zxingcpp.winrt

When building and deploying in VS, the appx (release) / deploy from layout (debug) includes the binaries and the functionality works fine.

When using run-windows --release, the deployed appx includes the binaries and everything runs fine.

When using run-windows (aka debug, our custom deploy from layout), the outputted folder does not contain the binaries. So when trying to scan for barcodes, we get a runtime exception:

Exception thrown at 0x762BC942 (KernelBase.dll) in BarcodeScannerApp.exe: WinRT originate error - 0x8007007E : 'The specified module could not be found.'. occurred

Callstack:

ReactNativeCameraCPP.dll!winrt::hresult_error::originate(const winrt::hresult code, void * message) Line 4503 C++ ReactNativeCameraCPP.dll!winrt::hresult_error::hresult_error(const winrt::hresult code, winrt::take_ownership_from_abi_t formal) Line 4428 C++ ReactNativeCameraCPP.dll!winrt::throw_hresult(const winrt::hresult result) Line 4688 C++ ReactNativeCameraCPP.dll!winrt::check_hresult(const winrt::hresult result) Line 4735 C++ ReactNativeCameraCPP.dll!winrt::get_activation_factory<winrt::ZXing::IBarcodeReaderFactory>(const winrt::param::hstring & name) Line 5737 C++ ReactNativeCameraCPP.dll!winrt::impl::factory_cache_entry<winrt::ZXing::BarcodeReader,winrt::ZXing::IBarcodeReaderFactory>::call<winrt::ZXing::BarcodeReader (const winrt::ZXing::IBarcodeReaderFactory &) &>(winrt::ZXing::BarcodeReader::winrt::ZXing::BarcodeReader (const winrt::ZXing::__IBarcodeReaderFactory &) & callback) Line 5964 C++ ReactNativeCameraCPP.dll!winrt::impl::call_factory<winrt::ZXing::BarcodeReader,winrt::ZXing::IBarcodeReaderFactory,winrt::ZXing::BarcodeReader (const winrt::ZXing::IBarcodeReaderFactory &)>(winrt::ZXing::BarcodeReader::winrt::ZXing::BarcodeReader (const winrt::ZXing::__IBarcodeReaderFactory &) && callback) Line 6006 C++ ReactNativeCameraCPP.dll!winrt::ZXing::BarcodeReader::BarcodeReader(bool tryHarder, bool tryRotate, winrt::array_view types) Line 130 C++ ReactNativeCameraCPP.dll!winrt::ReactNativeCameraCPP::ReactCameraView::ScanForBarcodeAsync$_ResumeCoro$2() Line 897 C++

Environment

If you are using latest version:

  1. react-native -v:

    4.10.1

  2. react-native run-windows --info:

    System: OS: Windows 10 10.0.20180 CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz Memory: 2.62 GB / 15.84 GB Binaries: Node: 12.9.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD npmPackages: react: 16.11.0 => 16.11.0 react-native: ^0.62.0-0 => 0.62.2 react-native-windows: ^0.62.0-0 => 0.62.4 Installed UWP SDKs: 10.0.18362.0

  3. reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"

AllowDevelopmentWithoutDevLicense    REG_DWORD    0x1
AllowAllTrustedApps    REG_DWORD    0x1

Then, specify:

Steps to Reproduce

  1. Create a new RNW app A
  2. Add a new C++/WinRT project B to the solution for A a. Add a dependency on a winrt nuget package C
  3. Add the new project B as a reference to the RNW app A
  4. Run react-native run-windows

Expected Behavior

The binaries from the nuget package C should have been transitively included in the app layout for the RNW app A, since the app depends on B and B depends on C.

Actual Behavior

Reproducible Demo

I can't publish my test app until my PR for barcode scanning gets merged into react-native-camera and released.

chrisglein commented 4 years ago

Let's look at this when we have the repro firmed up when the camera change has been merged.

jonthysell commented 4 years ago

Repo here in the new CameraDemo sample: https://github.com/microsoft/react-native-windows-samples/pull/186

Source: https://github.com/microsoft/react-native-windows-samples/tree/master/samples/CameraDemo

jonthysell commented 4 years ago

Running into this again as I work on #3278

jonthysell commented 4 years ago

Confirming today that this doesn't repro with a C# app consuming a C++ module + a C++ nuget.

jonthysell commented 4 years ago

Confirming today that this no longer repros with CameraDemo against the latest 0.63.

jonthysell commented 4 years ago

Closing as resolved for 63.