Skip to content

Conversation

@matthargett
Copy link
Contributor

@matthargett matthargett commented Oct 12, 2018

Test Plan:

I have a local Linux build (under Windows 10 WSL running Ubuntu 18.04) where I load an app bundle and ensure it doesn't crash, and run some of the gtest tests. I am currently unable to reproduce the cxxreact build in OSS, but this seems to be a known issue. For the record, my commandline for building and running the tests (after using vcpkg to install double-conversion, glog, gflags, and folly):
clang++-6.0 -fuse-ld=gold -o cxxreact-test_clang6_O3_lto_marchnative_g3 -std=c++14 -O3 -flto -g3 -march=native -L/mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/lib -I/mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/include -I/usr/include/webkitgtk-4.0/ -I. -ljavascriptcoregtk-4.0 -lfolly -lglog -ldouble-conversion fabric/events/*.cpp fabric/events/tests/EventsTest.cpp fabric/debug/*.cpp fabric/debug/tests/DebugStringConvertibleTest.cpp cxxreact/*.cpp cxxreact/tests/*.cpp microprofiler/*.cpp jsinspector/*.cpp privatedata/*.cpp jschelpers/JSC*.cpp jschelpers/[UV]*.cpp fabric/core/primitives/*.cpp fabric/core/tests/PrimitivesTest.cpp -lgtest -lgtest_main /mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/lib/libfolly.a /mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/lib/libgtest*.a /mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/lib/libglog.a /mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/lib/libdouble-conversion.a /mnt/c/Users/matt/workspace/vcpkg/installed/x64-linux/lib/libgflags.a -lpthread

Only two tests fail, which I will investigate and try to fix in a separate PR:

[----------] 2 tests from JSBigFileString
[ RUN      ] JSBigFileString.MapWholeFileTest
unknown file: Failure
C++ exception with description "basic_string::_M_construct null not valid" thrown in the test body.
[  FAILED  ] JSBigFileString.MapWholeFileTest (4 ms)
[ RUN      ] JSBigFileString.MapPartTest
unknown file: Failure
C++ exception with description "basic_string::_M_construct null not valid" thrown in the test body.
[  FAILED  ] JSBigFileString.MapPartTest (3 ms)
[----------] 2 tests from JSBigFileString (20 ms total)

Changelog:

[INTERNAL] [ENHANCEMENT] [ReactCommon/cxxreact] -Fix portability issues on Linux, FreeBSD, and older libc++ to enable fast unit and integration testing

  • Fix missing includes that happen to work on some libc++ implementations due to transitive inclusion, like unistd.h
  • Don't register hooks that rely on JSGlobalContextEnableDebugger and other things not available on all platforms (e.g. libjavascriptcoregtk-4.0) by guarding with APPLE and ANDROID
  • Add nullptr checks for optionally set global functions before using them
  • add getGlobalVariable to enable finer-grained unit testing

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 12, 2018
@shergin
Copy link
Contributor

shergin commented Oct 18, 2018

Oh nice! Thank you!
Could you please,

  • Rebase on the fresh master. Seems a bunch of modified files were removed.
  • Split this PR into a few logically isolated pieces (e.g. changing includes, using unique_ptr instead of shared_ptr, exceptions and so on.)

@matthargett
Copy link
Contributor Author

Extracted glog changes to #21915 . Will rebase this one once that is merged.

@hramos hramos added the c: Sony label Jan 25, 2019
@pull-bot

This comment has been minimized.

…ptr<T> to a base class, but shared_ptr<> does.
@hramos
Copy link
Contributor

hramos commented Jan 30, 2019

Just talked to Marc, who will be taking a look at this soon. I’ll wait for his feedback before proceeding.

@mhorowitz
Copy link
Contributor

My feedback is mainly about the API change to Instance::initializeBridge in 933253b.

What platform are you using with Dinkumware? The callers here are in iOS and Android specific code, and I'm surprised you can target either without using the Apple or Google libraries. The code in cxxreact is intended to be more portable, though.

I'm not excited about changing the API to support a flawed standard library. But, it should be possible to fix this without changing the API. Keep the argument typed as a unique_ptr, and instead of using std::make_unique or std::shared_ptr, avoid the implicit conversion by writing out the construction, like

std::unique_ptr<InstanceCallback>(new JInstanceCallback(...))

for example. make_unique is convenient for avoiding verbose code, but making this change should not change any semantics or behavior, so I think it's a better change if you need to hack things to deal with the toolchain. If the usage is in some code which isn't in the repo, then you can avoid making this diff at all, and just use the above style in your own code.

Finally, you should remove the android/log.h header in that commit, since it's likely to break Android builds.

@hramos hramos added the Partner label Jan 31, 2019
@matthargett
Copy link
Contributor Author

Thanks for taking the time to review!

The explicit cast didn't work for me, and I had tried that in September when I first ran into the issue. Something about what you said gave me a fresh idea, and what I ended up doing was wrapping the unique_ptr<> arg in a std::move() so the destructor wouldn't get triggered in the callsite context. That worked! I changed the shared_ptr<> back to unique_ptr<> in the CxxReact, iOS, and Android code.

Not sure how that log.h ended up there -- some weird auto-merge fail? I rm'd it.

If there's any more feedback, please let me know.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jan 31, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

@matthargett merged commit 36916ee into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Feb 1, 2019
@react-native-bot react-native-bot added the Merged This PR has been merged. label Feb 1, 2019
@hramos hramos removed the Core Team label Feb 5, 2019
@facebook facebook unlocked this conversation Feb 5, 2019
facebook-github-bot pushed a commit that referenced this pull request Feb 5, 2019
Summary:
This removes the accidental double include of the header `unistd.h` from `JSBigString.h`. One was added by me as part of #22330, and one by matthargett as part of #21764

[General] [Fixed] - `JSBigString.h`: Removed accidental double include of header `unistd.h`
Pull Request resolved: #23297

Differential Revision: D13961223

Pulled By: hramos

fbshipit-source-id: c0dba8a475b3c09356d34cb65b989c286793fa67
@matthargett matthargett deleted the cxxreact-portability branch February 6, 2019 21:49
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
matt-oakes pushed a commit to matt-oakes/react-native that referenced this pull request Feb 7, 2019
Summary: Pull Request resolved: facebook#21764

Differential Revision: D13902907

Pulled By: hramos

fbshipit-source-id: 640cde865b1bcc5ca43c17d00574b8e2f78ceaf4
matt-oakes pushed a commit to matt-oakes/react-native that referenced this pull request Feb 7, 2019
Summary:
This removes the accidental double include of the header `unistd.h` from `JSBigString.h`. One was added by me as part of facebook#22330, and one by matthargett as part of facebook#21764

[General] [Fixed] - `JSBigString.h`: Removed accidental double include of header `unistd.h`
Pull Request resolved: facebook#23297

Differential Revision: D13961223

Pulled By: hramos

fbshipit-source-id: c0dba8a475b3c09356d34cb65b989c286793fa67
KusStar pushed a commit to KusStar/react-native that referenced this pull request Oct 29, 2020
Summary: Pull Request resolved: facebook#21764

Differential Revision: D13902907

Pulled By: hramos

fbshipit-source-id: 640cde865b1bcc5ca43c17d00574b8e2f78ceaf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants