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

feat(android): add JSPointerDispatcherCompat for RN < 0.72 #681

Merged
merged 5 commits into from
Nov 12, 2024

Conversation

gronxb
Copy link
Contributor

@gronxb gronxb commented Nov 12, 2024

📜 Description

To add a compatibility layer for JSPointerDispatcher, ensure that the method functions correctly regardless of whether it is called with two or three parameters.

💡 Motivation and Context

Related:
facebook/react-native@1e53f88#diff-e874545c1f508ac02d63d67356fe0519f6c0dd5f380afeb900cf1de4fce6835aL202-R203

With the change, the number of parameters has increased from two to three. Since React Native 0.71.14 only uses two parameters, this causes a build error on Android.

📢 Changelog

Android

  • add JSPointerDispatcherCompat class

🤔 How Has This Been Tested?

  • I've tried compiling from 0.71
  • I've tried compiling from 0.76
  • I would like to test the compatibility layer to ensure it functions smoothly. Could you help me with a plan for testing this code?

📸 Screenshots (if appropriate):

image

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko
Copy link
Owner

thank you @gronxb for a contribution 🙌

Let me approve and run e2e tests to see if they pass or not 👀

Copy link
Contributor

github-actions bot commented Nov 12, 2024

📊 Package size report

Current size Target Size Difference
159441 bytes 159127 bytes 314 bytes 📈

@kirillzyusko
Copy link
Owner

I would like to test the compatibility layer to ensure it functions smoothly. Could you help me with a plan for testing this code?

I think running e2e tests should be enough. I'm testing there that Touchables from react-native and react-native-gesture-handler works as expected. So if you didn't break anything, then tests should pass - let's see 👀

@kirillzyusko kirillzyusko self-assigned this Nov 12, 2024
@kirillzyusko kirillzyusko added 🤖 android Android specific 🐛 bug Something isn't working labels Nov 12, 2024
@gronxb
Copy link
Contributor Author

gronxb commented Nov 12, 2024

@kirillzyusko Since ktlint was failing, I executed ktlint.

@kirillzyusko
Copy link
Owner

@gronxb detekt still fails 🙈

@kirillzyusko kirillzyusko merged commit 47b1581 into kirillzyusko:main Nov 12, 2024
16 checks passed
@kirillzyusko kirillzyusko mentioned this pull request Nov 13, 2024
2 tasks
kirillzyusko added a commit that referenced this pull request Nov 13, 2024
## 📜 Description

In
#681
we started to use reflection for detection the amount of params. But
reflection is a slow mechanism, so in this PR I'm optimizing lookup
stage by calculating a correct method only one time.

## 💡 Motivation and Context

Lookup can be up to 10-100 times slower comparing to the direct function
call. If we call this method too frequently, we can encounter a
bottleneck. To make this code faster I decided to cache the method (thus
we do a lookup only one time).

This approach should almost neglect performance impact for a lookup
stage. The call stage (method invocation) still will add an overhead,
but it should have a small impact.

## 📢 Changelog

### Android

- cache method (make it lazy calculated);
- move constants to companion object.

## 🤔 How Has This Been Tested?

Tested on CI.

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Android specific 🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants