microsoft / react-native-windows

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

'System.AccessViolationException' in Facebook.Yoga.dll #1027

Closed vince-rowe closed 7 years ago

vince-rowe commented 7 years ago

The app is running fine in simulator by react-native run-windows, but it will not run on a device through Visual Studio 2015 DebugRelease ARM. I have run the packaging command as per the docs.

It seems an issue with Facebook Yoga, but I think this is the best place to report?

Running facebook.yoga version 1.1.0.18-pre on the ReactNative package (not the app package).

Exception thrown: 'System.AccessViolationException' in Facebook.Yoga.dll The thread 0x92c has exited with code 0 (0x0). The thread 0x11d4 has exited with code 0 (0x0). The thread 0x10cc has exited with code 0 (0x0). The program '[4644] Name.exe' has exited with code 0 (0x0).

Any thoughts? Vince

andrewwebber commented 7 years ago

Can confirm I get the same issue

'testapp.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\SharedData\PhoneTools\AppxLayouts\81e1c535-6804-4f0c-8a3b-041215426f68VS.DebugBundle_ARM.AWebber\Facebook.Yoga.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. [JS Info] Running application "testapp" with appParams: {"rootTag":1,"initialProps":null}. DEV === true, development-level warning are ON, performance optimizations are OFFException thrown: 'System.AccessViolationException' in Facebook.Yoga.dll The thread 0x5b0 has exited with code 0 (0x0).

yoga

rozele commented 7 years ago

Sounds like an issue with the ARM build for Facebook.Yoga. Any thoughts @rmarinho?

andrewwebber commented 7 years ago

@rozele I feel so much confidence as soon as you reply to a thread. Stuff gets done :) I am unfortunately blocked here upgrading my app

andrewwebber commented 7 years ago

@rozele are you able to explain a little bit about the versioning here. Presumably ReactNative C# is maintained on this repro and a specific version of Facebook.Yoga is supported, as defined in the package.json. Assuming this issue is due to the PInvoke library being out of sync with the C# wrapper can we not pin the versions that are compatible? Or have I misunderstood

rozele commented 7 years ago

I don't think the P/Invoke library is out of sync. We actually don't touch P/Invoke code, that's all handled in the Facebook.Yoga package. There's a few new releases of Facebook.Yoga, let's try an upgrade and see if this is something that was already fixed.

rmarinho commented 7 years ago

Yo , can you try with our myget feed one of the last versions..

https://www.myget.org/F/yoga/api/v3/index.json

andrewwebber commented 7 years ago

@rmarinho how can i take advantage of your last comment, what are the steps

rmarinho commented 7 years ago

@andrewwebber what IDE are you using ?

rozele commented 7 years ago

@andrewwebber @rmarinho, I posted a PR ^^, if you can pull in those changes, let me know if the issue is still there. Still working on getting an ARM device to test on.

andrewwebber commented 7 years ago

@rmarinho atom.io + VSCommunity 2015

andrewwebber commented 7 years ago

@rozele thanks, ill check it out...

rozele commented 7 years ago

@andrewwebber if you don't want to merge any changes, you should just be able to go to the NuGet Package Manager Console and upgrade all the projects to 1.1.0.23-pre.

andrewwebber commented 7 years ago

@rozele @rmarinho I was able to successfully deploy the playground to my local machine but it fails on a windows phone. "Facebook.Yoga": "1.1.0.23-pre",

 react-native bundle --platform windows --entry-file ReactWindows/Playground/index.windows.js --bundle-output ReactWindows/Playground/ReactAssets/index.windows.bundle --assets-dest ReactW    indows/Playground/ReactAssets

I already get access violations on many properites after the default constructor is called.

image

andrewwebber commented 7 years ago

@rozele @rmarinho

After cloning and attaching the Yoga project I landed at the following exception. Again could poor configuration my side...

Is there any way to verify which DLLs are deployed to the phone

image

matthargett commented 7 years ago

Is this related to #1032 ?

rmarinho commented 7 years ago

@andrewwebber can you check if you have yoga.dll on your bin/debug/arm ? is this UWP or Windows 8.1 ?

andrewwebber commented 7 years ago

@rmarinho I am running UWP. I will check tomorrow as my company's Phone is in the office. I have the feeling that I cannot verify if yoga.dll is copied during the build. Is there a output windows to verify this? In the old days there was a property window field like "copy to output" :)

I just realized I can check this quickly without the device...

andrewwebber commented 7 years ago

@rmarinho After building the stock template the following can be found in the ARM folder

image

I would assume if they are in the ARM folder they get deployed to the device... image

rmarinho commented 7 years ago

Hum, yap it's there.. so it's UWP on a ARM device, wasn't this the fix you did recently @rozele that you tracked down with the UWP team ?

rozele commented 7 years ago

@rmarinho I had a slightly different issue. The UWP build was not targeted for the store, so it was linked against the incorrect VC runtime. I compiled today against the latest NuGet package and ran dumpbin /headers yoga.dll to confirm the DLL was ARM and had the correct dependencies. Everything looked good.

andrewwebber commented 7 years ago

Is there a vendoring/versioning concept here? It is possible to rollback to an older working version and still use 0.41 for example?

rozele commented 7 years ago

@andrewwebber I think the AccessViolationException and DllNotFoundException are two unrelated issues. Can you confirm if you revert back to Facebook.Yoga@1.1.0.18-pre that you still get the AccessViolationException? I think this is a broader issue than just ARM, as #1032 references a similar issue.

@rmarinho Has there been any changes to the build between 1.1.0.18-pre to 1.1.0.23-pre that may explain why we were previously building a valid ARM binary and now not?

andrewwebber commented 7 years ago

@rozele I am convinced that the DllNotFoundException is not the issue because I tried to setup a consolidate solution file with all the relevant projects in order to step into. I think my solution was not correct and did not copy the native DLL.

The first access violation is the real problem.

rmarinho commented 7 years ago

Yap, i m trying to get a hold of a device to test this..

andrewwebber commented 7 years ago

@rmarinho any luck finding an ARM device :)

rozele commented 7 years ago

@andrewwebber sorry for the delay, I finally got an ARM device with the latest Windows 10 bits and have a repro. I think I understand the problem.

rozele commented 7 years ago

@andrewwebber I'm also getting the DllNotFoundException when adding a test Universal Windows app to the Facebook.Yoga project. Did you ever resolve the DllNotFoundException when the Facebook.Yoga dependency is consumed locally?

@rmarinho The repro for ARM is actually quite simple:

var node = new YogaNode();
var leftPadding = node.PaddingLeft.Value;

The expected value of leftPadding is NaN, but instead it results in an AccessViolationException.

rozele commented 7 years ago

An update: I've narrowed the problem down to P/Invoke calls that return the YogaValue struct on ARM. Doing further testing to figure out what kinds of structs fail.

rozele commented 7 years ago

Another update: only structs containing enum members produce the AccessViolationException, and only on ARM builds. I've hacked together a workaround and may post a NuGet package just to unblock the 0.40 and 0.41 releases https://github.com/facebook/yoga/pull/459

andrewwebber commented 7 years ago

@rozele where can i find the patched version of yoga or is this already updated when creating a new app and installing react-native-windows?

rozele commented 7 years ago

@andrewwebber I'll be publishing new versions of react-native-windows@0.40, 0.41, and 0.42 today, but in the meantime you can just upgrade your NuGet dependency to Facebook.Yoga@1.2.0-pre1

andrewwebber commented 7 years ago

@rozele I get the following error on ARM after creating an empty app

image

andrewwebber commented 7 years ago

@rozele after deleting and re-creating the app building I get:

The system cannot find the file specified. (Exception from HRESULT: 0x80070002) Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.ni.dll

andrewwebber commented 7 years ago

Ok i forgot to bundle before building the debug offline version :( sorry

The "Welcome to React Native" example app now works again on ARM, thank you!