Skip to content

Conversation

@MikeOrtiz
Copy link
Contributor

Motivation: Arc drawing has been broken on Android for some time. @dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

Reproducing the Bug: dgladkov made a simple test app which helps to illustrate the bug. The repo can be found here. The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. Direct Link to iOS Before. Direct Link to Android Before.

Proof The Bug is Fixed: Here is a direct link to Android After pic. You can see the wedges match the iOS Before screenshot.

What went wrong: dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should always be positive. Java returns the remainder, which can be negative. -120 % 360 will return 240 in Python, but -120 in Java. I created a modulus method which mimics Python's behavior. Math.floorMod(), introduced in Java 8, also gets the job done. See this StackOverflow answer for more information regarding modulus.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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!

@sophiebits
Copy link
Contributor

To be fair, lots of languages implement % like this.

if (!clockwise) {
end = 360 - end;
start = end;
sweep = 360 - sweep;
Copy link
Contributor

Choose a reason for hiding this comment

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

If start === end already and sweep is 0, is this correct?

@MikeOrtiz
Copy link
Contributor Author

@spicyj Good catch. That edge case would create a full circle in counter-clockwise mode. I have a fix in place, but first a question: what is the expected result of an arc with startAngle = -360 and endAngle = 20? In my implementation, the result is a full circle, but I guess the argument could be made for a 20 degree arc. The ART docs, unfortunately, do not describe Path.arc().

@sophiebits
Copy link
Contributor

@facebook-github-bot
Copy link
Contributor

@MikeOrtiz updated the pull request.

@MikeOrtiz
Copy link
Contributor Author

I decided it was best to mimic the behavior of iOS. If the sweep > 360, then a full circle is always drawn. If sweep = 0, no wedge is drawn. Comparison screenshots: iOS and Android. The start/end angles are as follows:

Blue: start: 120, end: 220
Red: start: 120, end: 120
Green: start: -360, end: 20
Orange: start: 120, end: 20

@facebook-github-bot
Copy link
Contributor

@MikeOrtiz updated the pull request.

@facebook-github-bot
Copy link
Contributor

@MikeOrtiz updated the pull request.

@MikeOrtiz
Copy link
Contributor Author

@spicyj, I realized I didn't mention you in my last post. Not sure if that makes a difference.

@MikeOrtiz
Copy link
Contributor Author

The post isn't yet tagged as such, but I have signed the CLA.

@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!

@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 Apr 21, 2016
@mkonicek
Copy link
Contributor

Assigning to @spicyj who started reviewing this PR.

@tomauty
Copy link

tomauty commented Apr 27, 2016

Hooray :) This is a blocker for my project.

@sophiebits
Copy link
Contributor

Can you say whether this matches the SVG behavior now? I am fairly sure that is what ART intends to do for this path component.

@tomauty
Copy link

tomauty commented Apr 27, 2016

The fixed behavior seems to conform to intentions. The repo provided uses the Wedge component from react-art, in any case.

@sophiebits
Copy link
Contributor

Yeah, that seems fair. @facebook-github-bot shipit

@sophiebits
Copy link
Contributor

@facebook-github-bot shipit

@ghost ghost added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Apr 28, 2016
@ghost
Copy link

ghost commented Apr 28, 2016

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in 1af4760 Apr 28, 2016
@sophiebits
Copy link
Contributor

sophiebits commented Apr 28, 2016

It looks like this breaks circle rendering:

screen shot 2016-04-28 at 3 42 26 pm

const {Surface, Group} = require('ReactART');
const Circle = require('Circle.art');

...

  <Surface width={200} height={200}>
    <Group x={100} y={100}>
      <Circle radius={50} stroke="green" strokeWidth={3} fill="blue" />
    </Group>
  </Surface>

(where Circle.art comes from https://github.com/reactjs/react-art/blob/d1eda4fd8e3ee9462c32d2f611923697195fee14/src/Circle.art.js).

There should not be a line in the middle. I have to revert this commit (13acd7e), but would you want to send a follow-up that fixes this?

ghost pushed a commit that referenced this pull request Apr 28, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes #7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
fbshipit-source-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
@MikeOrtiz
Copy link
Contributor Author

Aww, yeah I'll look into it. When should I submit the fix to get it in for the upcoming release?

@sophiebits
Copy link
Contributor

I think we cut a release every other Sunday, including this weekend.

@MikeOrtiz
Copy link
Contributor Author

MikeOrtiz commented Apr 29, 2016

I just ran this on my machine and it looks fine. This is what it looks like for me. The call to close() in Circle.art is what will create the line segment to close off the final arc. If the path ends at the same point that it starts, there will be no line segment. This functionality is described in the Android Path docs here. The arcs are centered around the same coordinate and the second ends at the same angle the first begins, so the starting points should be identical. I printed some logs of Circle.art to confirm that fact:

04-29 01:54:38.488 1972-2038/com.testproject D/dsf: x: 140.0 y: 280.0 r: 140.0 start: -90.0 end: 90.0 sweep: 180.0
04-29 01:54:38.488 1972-2038/com.testproject D/dsf: x: 140.0 y: 280.0 r: 140.0 start: 90.0 end: -90.0 sweep: 180.0

I don't understand how you got this rendering, but I can't reproduce it.

One simple fix would be to remove the call to close() in Circle.art as it doesn't achieve anything, anyway.

@sophiebits
Copy link
Contributor

Hm, I'm not sure. I was testing on a Nexus 4 simulator on 4.4.4 (API 19).

@MikeOrtiz
Copy link
Contributor Author

@spicyj It looks like my changes weren't what broke this. The circle draws correctly up to #4e5c85 of my repo. At some point after that, someone introduced breaking code and my change exposed that break. I will run git bisect when I have time later today to pinpoint the breaking commit.

@sophiebits
Copy link
Contributor

Sounds good.

@MikeOrtiz
Copy link
Contributor Author

I couldn't successfully bisect the commits. After commit #47a470a, I get the red screen of death with the message "Couldn't get the native call queue...". Restarting package manager, reinstalling, etc didn't fix the issue. The message shows for this commit and all subsequent commits. Any hint would could be going wrong?

Circle rendered fine in the commit before that though.

@sophiebits
Copy link
Contributor

I'm not sure, sorry. Does master work for you? (I don't really work on Android, or on React Native for that matter.)

ptmt pushed a commit to ptmt/react-native that referenced this pull request May 9, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes facebook#7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
fbshipit-source-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
ptmt pushed a commit to ptmt/react-native that referenced this pull request May 9, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes facebook#7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
fbshipit-source-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes facebook#7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
fbshipit-source-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes facebook#7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
fbshipit-source-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
bubblesunyum pushed a commit to iodine/react-native that referenced this pull request Aug 23, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes facebook#7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
fbshipit-source-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
bubblesunyum pushed a commit to iodine/react-native that referenced this pull request Aug 23, 2016
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes facebook#7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
fbshipit-source-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
This pull request was closed.
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. Import Started This pull request has been imported. This does not imply the PR has been approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants