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

Two ReactART TODOs implemented on Android #9486

Closed
wants to merge 34 commits into from

Conversation

tepamid
Copy link
Contributor

@tepamid tepamid commented Aug 19, 2016

Implemented 2 TODOs from ReactART for Android:

  • TODO(7255985): Use TextureView and pass Surface from the view to draw on it asynchronously instead of passing the bitmap (which is inefficient especially in terms of memory usage)
  • TODO(6352067): Support dashes in ARTShape

We use ReactNativeART in our Android project.

  1. Our app crashes sometimes on large screen smartphones with OutOfMemoryError. Crashes happen in ARTSurfaceShadowNode where TODO(7255985) was suggested in a comment in order to use memory more efficiently.
  2. We needed dashes for drawing on ARTSurface.

Test plan (required)

I attach a screenshot of our app which shows dashed-lines and two ARTSurfaces on top of each other rendering exactly the same as in the pervious implementation of ARTSurface.
screenshot_2016-08-19-16-45-43

@ghost
Copy link

ghost commented Aug 19, 2016

By analyzing the blame information on this pull request, we identified @spicyj and @emilsjolander to be potential reviewers.

@ghost
Copy link

ghost commented Aug 19, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@ghost
Copy link

ghost commented Aug 19, 2016

@tepamid updated the pull request - view changes

@ghost ghost 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 Aug 19, 2016
@ghost
Copy link

ghost commented Aug 19, 2016

@tepamid updated the pull request - view changes

@ghost ghost 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 Aug 19, 2016
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@ghost
Copy link

ghost commented Aug 19, 2016

@tepamid updated the pull request - view changes

@ghost ghost 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 Aug 19, 2016
@ghost
Copy link

ghost commented Aug 20, 2016

@tepamid updated the pull request - view changes

@ghost ghost 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 Aug 20, 2016
@ghost ghost 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 Aug 20, 2016
geof90 and others added 7 commits August 21, 2016 11:33
Summary:
Fix regression of rnpm/rnpm-plugin-link#88.
Closes facebook#9252

Differential Revision: D3680785

fbshipit-source-id: a6ea63295ae8f61b17c0a1b2ca5e6a5f5da7437a
Summary:
`this` is a `ReactNativeHost` post RN 0.29, so the current patch doesn't compile. Simply `getResources()` will work for all versions - Post RN 0.29, it will be the method in the outer `MainApplication`, Pre RN 0.29, it will be the method on the `MainActivity`.

grabbou Kureev
Closes facebook#9381

Differential Revision: D3744162

fbshipit-source-id: 1fa270bb3268b7b40c6160da948d99ff993c83b1
Summary:
React 15.3.0 was officially released. We especially should try not depend on RCs in RN releases and npm doesn't handle RC versions well.
Closes facebook#9279

Differential Revision: D3683587

fbshipit-source-id: fc4f8a030769232b7697434a419e1e07e482e308
fbshipit-source-id: 0373b4dd11895f3b1c76a904a0a59b70aaa845f9
fbshipit-source-id: c25ad1b942e75d9a631134fc277306931c7bc859
Reviewed By: davidaurelio

Differential Revision: D3683793

fbshipit-source-id: 6ffb8c24e81cfb33b11b9f99d440220287161fb6
@fkling fkling removed their assignment Sep 25, 2016
@ghost ghost 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 Sep 25, 2016
@robclouth
Copy link
Contributor

Hey, what's the status of this?

@robclouth
Copy link
Contributor

I'm trying this code, and it seems that despite calling markChildrenUpdatesSeen, onCollectExtraUpdates is only called once for each surface at startup before the Surface has been created, resulting in nothing being drawn. Any ideas?

@facebook-github-bot
Copy link
Contributor

@tepamid updated the pull request - view changes

@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, 2016
@facebook-github-bot
Copy link
Contributor

@tepamid updated the pull request - view changes

@foghina
Copy link
Contributor

foghina commented Oct 12, 2016

@tepamid did you get rid of the random IllegalArgumentExceptions?

@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, 2016
@facebook-github-bot
Copy link
Contributor

@tepamid updated the pull request - view changes

@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 13, 2016
@tepamid
Copy link
Contributor Author

tepamid commented Oct 13, 2016

@foghina I couldn't reproduce IllegalArgumentException myself, the code works fine. However in our production exception trackers (Raygun and Google Analytics) I rarely see that some users do face IllegalArgumentExceptions. Even more strange is that there are cases when the Surface is valid and can be successfully locked before drawing, but after drawing while unlocking the Surface IllegalArgumentException is thrown.

I googled this case and found a "holy-war" in stackoverflow whether adding try-catch around Surface locking-unlocking is a dirty hack or a reliability necessity. I personally tend to think it's a hack, but otherwise the app crashes which is even worse.

Finally, I ended with adding try-catch to handle random IllegalArgumentExceptions.

@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 13, 2016
@foghina
Copy link
Contributor

foghina commented Oct 13, 2016

@tepamid nice, thanks for the summary. Do you know what happens when you catch? Does the app end up in a bad state, or does the next draw go through correctly?

@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 13, 2016
@tepamid
Copy link
Contributor Author

tepamid commented Oct 13, 2016

@foghina before I had a synthetic testcase which reproduced IllegalArgumentException in drawing on ARTSurface. An exception happened when I navigated between app screens and the screen containing ARTSurfare was unmounted. I suspect that native Android TextureView can be unmounted during drawing process putting surface handle (i.e. Canvas or Surface) into an invalid state even after the surface had been previously locked. So there won't be any more render cycles for this unmounted component and therefore lockCanvas attempts.

Also exceptions occur either in lockCanvas or unlockCanvas methods. And not during drawing shapes on a canvas.

@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 13, 2016
@foghina
Copy link
Contributor

foghina commented Oct 14, 2016

Cool, thanks for the explanation! I'll go ahead and try to land this.

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are a Facebook employee, you can view this diff on Phabricator.

ahmedre pushed a commit that referenced this pull request Dec 19, 2016
Summary:
Implemented 2 TODOs from ReactART for Android:
- TODO(7255985): Use TextureView and pass Surface from the view to draw on it asynchronously instead of passing the bitmap (which is inefficient especially in terms of memory usage)
- TODO(6352067): Support dashes in ARTShape

We use ReactNativeART in our Android project.
1. Our app crashes sometimes on large screen smartphones with OutOfMemoryError. Crashes happen in ARTSurfaceShadowNode where TODO(7255985) was suggested in a comment in order to use memory more efficiently.
2. We needed dashes for drawing on ARTSurface.

**Test plan (required)**

I attach a screenshot of our app which shows dashed-lines and two ARTSurfaces on top of each other rendering exactly the same as in the pervious implementation of ARTSurface.
![screenshot_2016-08-19-16-45-43](https://cloud.githubusercontent.com/assets/18415611/17811741/cafc35c4-662c-11e6-8a63-7c35ef1c5ba9.png)
Closes #9486

Differential Revision: D4021303

Pulled By: foghina
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
Summary:
Implemented 2 TODOs from ReactART for Android:
- TODO(7255985): Use TextureView and pass Surface from the view to draw on it asynchronously instead of passing the bitmap (which is inefficient especially in terms of memory usage)
- TODO(6352067): Support dashes in ARTShape

We use ReactNativeART in our Android project.
1. Our app crashes sometimes on large screen smartphones with OutOfMemoryError. Crashes happen in ARTSurfaceShadowNode where TODO(7255985) was suggested in a comment in order to use memory more efficiently.
2. We needed dashes for drawing on ARTSurface.

**Test plan (required)**

I attach a screenshot of our app which shows dashed-lines and two ARTSurfaces on top of each other rendering exactly the same as in the pervious implementation of ARTSurface.
![screenshot_2016-08-19-16-45-43](https://cloud.githubusercontent.com/assets/18415611/17811741/cafc35c4-662c-11e6-8a63-7c35ef1c5ba9.png)
Closes facebook#9486

Differential Revision: D4021303

Pulled By: foghina
msand added a commit to msand/react-native-svg that referenced this pull request Feb 23, 2018
JackWillie added a commit to JackWillie/react-native-svg that referenced this pull request Nov 27, 2022
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet