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

Release underlying resources when JS instance is GC'ed on Android try 2 #26155

Closed

Conversation

janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Aug 22, 2019

Summary

Reland #24767

The commit had to be reverted because it caused a crash when using remote debugging in chrome. This is normal since jsi is not available in that environment. The crash was caused by jsContext.get() being 0, then being dereferenced later in c++. We can simply skip initializing the blob collector in this case.

This also includes the fix from #25720 to fix a crash when using hermes.

Changelog

[Android] [Fixed] - Release underlying resources when JS instance is GC'ed on Android

Test Plan

Test using RN tester with jsc and hermes
Test remote debugging

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. labels Aug 22, 2019
@janicduplessis
Copy link
Contributor Author

cc @makovkastar

@react-native-bot react-native-bot added Platform: Android Android applications. Bug labels Aug 22, 2019
@@ -25,6 +25,7 @@ rn_android_library(
react_native_target("java/com/facebook/react:react"),
react_native_target("java/com/facebook/react/common:build_config"),
react_native_target("java/com/facebook/react/modules/core:core"),
react_native_target("java/com/facebook/react/views/text:text"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this dependency introduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted 983ba63 to start this pr so it came from that. I’m not sure why it was it was added in the original commit. Should I just remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's remove it if it's not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

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.

@makovkastar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

@makovkastar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@makovkastar
Copy link
Contributor

@janicduplessis I've imported this PR, but it failed to compile when I tried to build with Buck:

stderr: xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BlobCollector.cpp:22: error: undefined reference to 'facebook::jsi::HostObject::~HostObject()'
buck-out/gen/xplat/jsi/jsiAndroid#header-mode-symlink-tree-with-header-map,headers/jsi/jsi.h:0: error: undefined reference to 'vtable for facebook::jsi::HostObject'

Could you please take a look?

@janicduplessis
Copy link
Contributor Author

@makovkastar I'm not able to reproduce the issue with the OSS buck setup, could you investigate this one? I did some tweaks to the buck file but I can't tell if it will fix the issue.

@janicduplessis
Copy link
Contributor Author

The text addition in the buck file was actually fixing the buck build for RN tester, there are quite a fe w more things that need to be fixed for the oss buck build of RN tester to work so I will open a separate PR for that.

@janicduplessis
Copy link
Contributor Author

@makovkastar Any change you can have a look at this again?

@makovkastar
Copy link
Contributor

makovkastar commented Sep 11, 2019

Hi @janicduplessis, I've been busy lately with some Fabric work and didn't have time to look into it. I will try to check it this evening, but no promises.

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.

@makovkastar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@makovkastar
Copy link
Contributor

I made a small change in the BUCK file and it's building now. I'm waiting for the code review from one of the teams that was affected last time we landed this PR. If everything is OK, I will merge it on Monday.

@mcuelenaere
Copy link
Contributor

Will this be backported to 0.60? This was a huge issue on our app and has caused a lot of lost engineering resources for us..

This merges with relatively little merge conflicts on 0.60-stable, see https://github.com/mcuelenaere/react-native/tree/backport/android-blob-gc-0.60

@talha-apps
Copy link

Any idea how soon can we get this? We have been waiting for this one for a long time. Will be great if someone can look at the broken tests so this can go in?

@makovkastar
Copy link
Contributor

This PR was accepted and now there are some internal tests being run before merging this. I will try to get this merged today.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @janicduplessis in 9b2374b.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 18, 2019
@talha-apps
Copy link

Thanks @makovkastar and @janicduplessis for resolving this. Looking forward to having this in the upcoming release. Any idea when that might be?

@janicduplessis janicduplessis deleted the blob-dealloc-android-2 branch September 18, 2019 17:08
@janicduplessis
Copy link
Contributor Author

@Talha-Ahmed I'll try to get it cherry-picked in the next 0.60.x release

mcuelenaere pushed a commit to getdelta/react-native that referenced this pull request Sep 24, 2019
… 2 (facebook#26155)

Summary:
Reland facebook#24767

The commit had to be reverted because it caused a crash when using remote debugging in chrome. This is normal since jsi is not available in that environment. The crash was caused by `jsContext.get()` being 0, then being dereferenced later in c++. We can simply skip initializing the blob collector in this case.

This also includes the fix from facebook#25720 to fix a crash when using hermes.

[Android] [Fixed] - Release underlying resources when JS instance is GC'ed on Android
Pull Request resolved: facebook#26155

Test Plan:
Test using RN tester with jsc and hermes
Test remote debugging

Reviewed By: mdvacca, fred2028

Differential Revision: D17072644

Pulled By: makovkastar

fbshipit-source-id: 079d1d43501e854297fbbe586ba229920c892584
@mcuelenaere
Copy link
Contributor

To people who are interested in this, we are keeping track of these changes at https://github.com/getdelta/react-native/tree/0.60-patched (prebuilt Android binaries are available at https://github.com/getdelta/react-native/tree/0.60-patched-prebuilt)

@talha-apps
Copy link

talha-apps commented Oct 7, 2019

This didn't get picked in 0.60.6. Can this please be released soon? @janicduplessis @makovkastar

grabbou pushed a commit that referenced this pull request Oct 11, 2019
… 2 (#26155)

Summary:
Reland #24767

The commit had to be reverted because it caused a crash when using remote debugging in chrome. This is normal since jsi is not available in that environment. The crash was caused by `jsContext.get()` being 0, then being dereferenced later in c++. We can simply skip initializing the blob collector in this case.

This also includes the fix from #25720 to fix a crash when using hermes.

## Changelog

[Android] [Fixed] - Release underlying resources when JS instance is GC'ed on Android
Pull Request resolved: #26155

Test Plan:
Test using RN tester with jsc and hermes
Test remote debugging

Reviewed By: mdvacca, fred2028

Differential Revision: D17072644

Pulled By: makovkastar

fbshipit-source-id: 079d1d43501e854297fbbe586ba229920c892584
douglowder pushed a commit to react-native-tvos/react-native-tvos that referenced this pull request Dec 11, 2019
… 2 (#26155)

Summary:
Reland facebook/react-native#24767

The commit had to be reverted because it caused a crash when using remote debugging in chrome. This is normal since jsi is not available in that environment. The crash was caused by `jsContext.get()` being 0, then being dereferenced later in c++. We can simply skip initializing the blob collector in this case.

This also includes the fix from facebook/react-native#25720 to fix a crash when using hermes.

## Changelog

[Android] [Fixed] - Release underlying resources when JS instance is GC'ed on Android
Pull Request resolved: facebook/react-native#26155

Test Plan:
Test using RN tester with jsc and hermes
Test remote debugging

Reviewed By: mdvacca, fred2028

Differential Revision: D17072644

Pulled By: makovkastar

fbshipit-source-id: 079d1d43501e854297fbbe586ba229920c892584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants