Skip to content

Remove Jackson dependency - #10521

Closed
belemaire wants to merge 4 commits into
react:masterfrom
belemaire:removeJacksonDependency
Closed

belemaire wants to merge 4 commits into
react:masterfrom
belemaire:removeJacksonDependency

Conversation

@belemaire

Copy link
Copy Markdown

This PR removes dependency to Jackson third-party library in Android React Native.

Looking at some older PRs that got merged, it seems like some work had already been done to move away from Jackson.

Anyway, there was only two classes left with a dependency on Jackson. I refactored the code to use android built-in JsonReader and JsonWriter classes instead.

Prep work was done in #10516 introducing a few unit tests around serialization, to make sure that refactoring around serialization would not break things.

All references to Jackson in build systems files (BUCK files & build.gradle) have also been removed now that no code depend anymore on this third-party library.

Motivation behind this work is that third-party dependencies in Android React Native can prove to be a pain when trying to integrate React Native components into an already existing large Android application (I know this is not the most common use case for react-native ... yet ;P), that might also depend on similar third-party libraries at a different version. Getting rid of Jackson was the easiest starter work as it's usage in the current code was very limited.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Oct 24, 2016
@belemaire belemaire changed the title Remove jackson dependency Remove Jackson dependency Oct 24, 2016
@hey99xx

hey99xx commented Oct 29, 2016 •

Copy link
Copy Markdown

This looks good to me, I also wanted to remove this dependency since it's so old, from 2013. I'm already including a newer version of Jackson in the app, so I have to increase version of Jackson of this dependency in my React fork.

One question though: If Jackson was indeed in so few files in the entire repository, why was it a dependency in the first place? Did it provide certain speed or space improvement over regular Android JSON classes? My experiences with org.json.JSONObject class have been nothing but unpleasant, so I'm curious if we're going to lose anything by removing Jackson

@belemaire

Copy link
Copy Markdown
Author

@hey99xx : Thanks for your post.
I am not sure why it was still a dependency, this is more a question to original maintainers. It seems like these file with Jackson dependency were added when react native Android was introduced (a while back) and never really looked into. I think it just did not really mattered because as I said, most use cases for React Native are pure React Native project and not integration into existing Android native application. Don't know why Jackson was used in the first place, maybe just for convenience.
Anyway, I don't think using built-in JsonReader/JsonWriter instead of Jackson have any impact. We don't lose anything functionally. Not sure about the performance, haven't looked into it, but I don't think this is a big concern. These classes are used for development only (so won't impact apps in production) and it's not like "high intensity/throughput" use apparently, so I don't think it will have any kind of impact.
That being said I can do some performance testing if deemed necessary, but I don't really think it matters for these classes.

@ide

ide commented Oct 31, 2016

Copy link
Copy Markdown
Contributor

@mkonicek do you know the answer to @belemaire's question about why Jackson is used? Can you merge this PR or assign it to someone who's responsible for the debugger WebSocket code?

@hramos

hramos commented Nov 11, 2016

Copy link
Copy Markdown
Contributor

I'll see if someone can take a look at this.

@mkonicek

mkonicek commented Nov 12, 2016 •

Copy link
Copy Markdown
Contributor

@ide Will try to find out why we used Jackson. Based on history @frantic and @kmagiera might have context. Asked them on messenger.

@kmagiera

Copy link
Copy Markdown
Contributor

We used jackson for performance reasons, although it historically has been used in the bridge implementation. Now that we only use it in debugger client it's reasonable to drop that dependency in favour of using builitin (slower) parser. Another option would be to make it dev only dependency but I think just getting rid of it completely makes better sense

@ide

ide commented Nov 13, 2016

Copy link
Copy Markdown
Contributor

@kmagiera thanks! Let's try to remove the dependency then.

@belemaire can you add to your first comment a test plan that shows you tested the modified code paths and that they still work?

@belemaire

Copy link
Copy Markdown
Author

Thanks all for your comments and the history note, make sense.
Sorry for delayed answer, I am currently out of town with limited connectivity. I'll be able to look more into anything on Monday if needed.

@kmagiera : Even so, he option of only making it a dev dependency won't entirely solve the problem. In our Android application we're also using Jackson during dev and for tests etc so some kind of versioning conflict still could happen. Don't know if I make sense ;P

@ide : In my initial comment for this PR I mentioned that I had done prep-work adding tests in #10516 which got merged a few weeks back.
I am sorry but I don't really get what you're expecting from me. The tests I added are covering the methods that have been modified, and ensure that serialized/deserialized output data are the expected ones. These tests were run on this PR by the CI (because they were merged prior to it) and all passed.
Could you please clarify what you'd like me provide (if you can point me to another PR or just explain) and I'll be happy to work on it. Thanks !

@ide

ide commented Nov 14, 2016

Copy link
Copy Markdown
Contributor

@belemaire I mean non-automated tests, what steps did you take to make sure this code works? Just 2-3 sentences is fine.

@mkonicek

mkonicek commented Nov 14, 2016 •

Copy link
Copy Markdown
Contributor

@belemaire Thanks for working on this, we should merge this.

Every pull request should have a Test Plan to make sure the code doesn't break anything: https://github.com/facebook/react-native/blob/master/.github/PULL_REQUEST_TEMPLATE.md

In this case, the PR summary should contain an explanation of how you tested debugging in Chrome works, e.g. "I ran this app, set a breakpoint here, here's a screenshot showing the Chrome debugger stopped at that breakpoint. Tried reloading JS, the app still works and Chrome debugger stopped at the breakpoint again. Disabled Chrome debugging, app works fine, Reload JS works fine." or similar.

The reason we have this test plan is because it helps reviewers understand the code doesn't break anything. Every commit internally at fb needs to have a test plan too. Sometimes the test plan misses something important, and the reviewer doesn't realize that either, and the code does break something. That's why the more detailed test plan the better.

Thanks for adding the unit tests in #10516! If the unit tests you added make it 100% certain debugging in Chrome still works with this pull request, you could simply say "Test Plan: Unit tests added in #10516". But since Chrome debugging is very complex it still seems safer to manually check the end-to-end workflow.

@belemaire
belemaire force-pushed the removeJacksonDependency branch from ddcf8e0 to 2ecca17 Compare November 15, 2016 00:17
@belemaire

belemaire commented Nov 15, 2016 •

Copy link
Copy Markdown
Author

@mkonicek @ide : Thanks for the precisions.

I totally get it. Even more because going through manual testing, I actually found a bug that was not covered by unit tests and made the app crash on start-up. Will keep that in mind for future PRs.

I updated the code to fix this bug and also added a few unit tests to cover these cases.

Please find manual test plan below :

The following test plan / steps have been conducted two times. First time, using current master code (without this PR code) and a second time using this PR modified code.
No differences have been noticed.

  • Created new react-native application from scratch using react-native init
  • Launched the app, made sure that it correctly loads from the packager
  • Reloaded the app, made sure that it correctly gets reloaded
  • Opened react native developer menu and clicked “Debug JS Remotely”. Made sure it opens a new chrome tab and that application successfully connects to the Chrome debugger.
  • Set a breakpoint in index.android.js in render method. Reloaded the app. Made sure that breakpoint was successfully hit.
  • Made sure that stepping through the code was working, going down the stack.
  • Made sure resuming execution works
  • Opened react native developer menu and clicked “Stop Remote JS Debugging”. Made sure there was no issue.
  • Reloaded the app, made sure that breakpoint was not hit.
  • Opened react native developer menu and clicked “Enable Live Reload”. Made sure there was no issue.
  • Modified index.android.js, changing text “Welcome to React Native” to “Welcome”. Saved the file and triggered a reload in the app. Made sure that there was no issue and that text was correctly updated after reload.
  • Opened react native developer menu and clicked “Enable Hot Reloading”. Made sure there was no issue.
  • Modified index.android.js changing “Welcome” text back to original text “Welcome to React Native”. Saved the file and made sure that app was automatically refreshed with correct new content upon file save.
  • Opened react native developer menu and click “Debug JS Remotely”. Made sure there was no issue.
  • Reloaded the app and made sure previously set breakpoint was still hit.
  • Resumed the execution after hitting breakpoint.
  • Closed chrome debugging tab. Made sure that red error screen was displayed with Exception “Websocket connection no longer valid”
  • Made sure clicking “Reload” on the red screen was actually re-opening a chrome tab for debuging and reloading the app.
  • Made sure reloading the app was still hitting the breakpoint
  • Closed chrome debugging tab again. Made sure that red error screen was displayed.
  • Made sure clicking “Dismiss” on the red screen was actually going back to the application.
  • Opened react native developer menu and clicked “Stop Remote JS Debugging”. Made sure there was no issue.
  • Opened react native developer menu and clicked "Debug JS Remotely". Made sure there was no issue and that new debugger tab was opened in Chrome.
  • Reloaded app to make sure breakpoint was still hit.
  • Resumed execution after hitting breakpoint.
  • While keeping chrome tab opened, closed the application and restarted it. Made sure that debugger session was correctly getting reconnected upon app start and that breakpoint was still hit.

Please let me know if you need more.

@mkonicek

Copy link
Copy Markdown
Contributor

Thanks a lot for testing this thoroughly @belemaire!

The Circle CI build failed with an unrelated error. I just hit rebuild.

@belemaire
belemaire force-pushed the removeJacksonDependency branch from 2ecca17 to 4ed5b5b Compare November 22, 2016 19:16
@belemaire

Copy link
Copy Markdown
Author

@mkonicek : Thanks for looking into this and relaunching a build.
Noticed the build failed for unrelated reasons once again.
I took the opportunity to rebase this branch off master and force pushed, triggering a new build in the way. Let's see how it goes.

@mkonicek

Copy link
Copy Markdown
Contributor

Tests passed now.

@facebook-github-bot shipit

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Nov 23, 2016
@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

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.

7 participants