-
Notifications
You must be signed in to change notification settings - Fork 453
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
react-native-sketch-canvas does not support new architecture even with RN v0.72 interop layer #236
Comments
@cipolleschi can you help here? |
@ravindraguptacapgemini @karthiktrcapgemini thanks for testing this. I don't have an immediate answer, as this error looks a bit hard to identify for me. This will make it easier for us to run it and see what's going wrong. Thank you so much! cc. @cortinico as this is also failing for Android |
Sure @cipolleschi, We will share a reproducible repo as soon as possible. |
@cipolleschi - Here is the reproducible repo for this -> https://github.com/karthiktrcapgemini/react-native-sketch-canvas-interop-layer-issue Adding a few more details - Android -
iOS -
|
Thanks for sharing this. |
Unfortunately, We are in the process of migrating one of our apps to new arch and this is one of the few blockers we are facing. Any way at all to expedite this or things we could check at our end in the meantime? @cipolleschi |
ok, I found some time to investigate this for iOS. I think that the root problem is in the logic of how the views are added/removed from the registry. The problem is that RNSketchCanvas expect the view to always be in the registry, so it tries to access the registry outside a command invocation (due to some async call) and that fails. I prepared this PR that should fix the issue on iOS, but we have to wait for @cortinico for Android. |
Thanks a lot @cipolleschi, this sounds great. I will keep this thread posted once I get a chance to test this fix for iOS |
I just want to highlight a thing. Although I really really appreciate the effort in migrating your app to the New Architecture, and all the feedback that comes with the migration, please remember that the New Architecture is still experimental. There will be breaking changes in the APIs while we work in releasing everything that's needed and there will be new pieces of the Architecture that will arrive in 0.73. |
Thanks @cipolleschi. Acknowledged. |
@cortinico we are getting this issue for multiple component, sketch-canvas is one of them, can you please check the reproducer and see what's breaking thing there. Hope to get your response, thanks. |
Hi @karthiktrcapgemini @ravindraguptacapgemini The problem is with commands & the interop layer. Specifically Line 93 in b322a86
I would need to wait for @cipolleschi to be back in the office next week to discuss this, but I noticed a change for iOS: facebook/react-native@c7aaae6 is causing all events to be delivered as We'll investigate further and get back with a fix as this is definitely affecting other libraries. |
Hi @cortinico Thanks for identifying the RC. Is there a tentative ETA on the PR or version with which the fix for this might be released? |
Hey @ravindraguptacapgemini @karthiktrcapgemini The fix will be shipped when it's ready |
Summary: This fixes a bug that got reported for the Fabric Interop for Android with Command dispatching. (See terrylinla/react-native-sketch-canvas#236) The problem is that libraries that were receiving commands as ints with: ``` public void receiveCommand( int surfaceId, int reactTag, int commandId, Nullable ReadableArray commandArgs) { ``` would not receive command with the Fabric Interop for Android. The problem is that with Fabric, events are dispatched as string always. cipolleschi took care of this for iOS, but we realized that the Android part was missing. I'm adding it here. The logic is, if the event is dispatched as a string that represents a number (say `"42"`) and the user has Fabric Interop enabled, then we dispatch the event as `int` (so libraries will keep on working). Changelog: [Android] [Fixed] - Fabric Interop - Properly dispatch integer commands Differential Revision: D47600094 fbshipit-source-id: a051eaf145cacaa275f520c46aeea95165f842a0
Summary: Pull Request resolved: facebook#38527 This fixes a bug that got reported for the Fabric Interop for Android with Command dispatching. (See terrylinla/react-native-sketch-canvas#236) The problem is that libraries that were receiving commands as ints with: ``` public void receiveCommand( int surfaceId, int reactTag, int commandId, Nullable ReadableArray commandArgs) { ``` would not receive command with the Fabric Interop for Android. The problem is that with Fabric, events are dispatched as string always. cipolleschi took care of this for iOS, but we realized that the Android part was missing. I'm adding it here. The logic is, if the event is dispatched as a string that represents a number (say `"42"`) and the user has Fabric Interop enabled, then we dispatch the event as `int` (so libraries will keep on working). Changelog: [Android] [Fixed] - Fabric Interop - Properly dispatch integer commands Reviewed By: cipolleschi Differential Revision: D47600094 fbshipit-source-id: 73fd3f5bdee860f1d371541b3bd0aa60a62e2981
Summary: Pull Request resolved: facebook#38527 This fixes a bug that got reported for the Fabric Interop for Android with Command dispatching. (See terrylinla/react-native-sketch-canvas#236) The problem is that libraries that were receiving commands as ints with: ``` public void receiveCommand( int surfaceId, int reactTag, int commandId, Nullable ReadableArray commandArgs) { ``` would not receive command with the Fabric Interop for Android. The problem is that with Fabric, events are dispatched as string always. cipolleschi took care of this for iOS, but we realized that the Android part was missing. I'm adding it here. The logic is, if the event is dispatched as a string that represents a number (say `"42"`) and the user has Fabric Interop enabled, then we dispatch the event as `int` (so libraries will keep on working). Changelog: [Android] [Fixed] - Fabric Interop - Properly dispatch integer commands Reviewed By: cipolleschi Differential Revision: D47600094 fbshipit-source-id: ee4b4829610c42304bcbf50bd27d2b4093dae760
Summary: Pull Request resolved: facebook#38527 This fixes a bug that got reported for the Fabric Interop for Android with Command dispatching. (See terrylinla/react-native-sketch-canvas#236) The problem is that libraries that were receiving commands as ints with: ``` public void receiveCommand( int surfaceId, int reactTag, int commandId, Nullable ReadableArray commandArgs) { ``` would not receive command with the Fabric Interop for Android. The problem is that with Fabric, events are dispatched as string always. cipolleschi took care of this for iOS, but we realized that the Android part was missing. I'm adding it here. The logic is, if the event is dispatched as a string that represents a number (say `"42"`) and the user has Fabric Interop enabled, then we dispatch the event as `int` (so libraries will keep on working). Changelog: [Android] [Fixed] - Fabric Interop - Properly dispatch integer commands Reviewed By: cipolleschi Differential Revision: D47600094 fbshipit-source-id: adb789abc529b9b1aa0dfcf979ac16856a31135d
Summary: Pull Request resolved: #38527 This fixes a bug that got reported for the Fabric Interop for Android with Command dispatching. (See terrylinla/react-native-sketch-canvas#236) The problem is that libraries that were receiving commands as ints with: ``` public void receiveCommand( int surfaceId, int reactTag, int commandId, Nullable ReadableArray commandArgs) { ``` would not receive command with the Fabric Interop for Android. The problem is that with Fabric, events are dispatched as string always. cipolleschi took care of this for iOS, but we realized that the Android part was missing. I'm adding it here. The logic is, if the event is dispatched as a string that represents a number (say `"42"`) and the user has Fabric Interop enabled, then we dispatch the event as `int` (so libraries will keep on working). Changelog: [Android] [Fixed] - Fabric Interop - Properly dispatch integer commands Reviewed By: cipolleschi Differential Revision: D47600094 fbshipit-source-id: c35f0509e6c6c0cddc7090a069882f92dd95532e
Summary: Pull Request resolved: #38527 This fixes a bug that got reported for the Fabric Interop for Android with Command dispatching. (See terrylinla/react-native-sketch-canvas#236) The problem is that libraries that were receiving commands as ints with: ``` public void receiveCommand( int surfaceId, int reactTag, int commandId, Nullable ReadableArray commandArgs) { ``` would not receive command with the Fabric Interop for Android. The problem is that with Fabric, events are dispatched as string always. cipolleschi took care of this for iOS, but we realized that the Android part was missing. I'm adding it here. The logic is, if the event is dispatched as a string that represents a number (say `"42"`) and the user has Fabric Interop enabled, then we dispatch the event as `int` (so libraries will keep on working). Changelog: [Android] [Fixed] - Fabric Interop - Properly dispatch integer commands Reviewed By: cipolleschi Differential Revision: D47600094 fbshipit-source-id: c35f0509e6c6c0cddc7090a069882f92dd95532e
Hi @cortinico, Thanks for releasing the above Android issue fix for this as part of 0.72.4. We have had the chance to test the fix and see an additional issue only with Android. This issue is completely fixed now with iOS with interop layer. Details below - React Native Version0.72.4 What platforms are you seeing the problem on?Android Device(s)Android Pixel 5 (API 33) IssueWe are now able to sketch on the canvas which we were previously unable to do as per our above post. But now, getBase64* method does not return the result base64 we need for the sketch. This works perfectly fine for iOS. Please see SSs below - *From the Documentation - iOSAndroidReproducer APP - I have updated the reproducer app to log the base64 result from the methodhttps://github.com/karthiktrcapgemini/react-native-sketch-canvas-interop-layer-issue |
Hi @karthiktrcapgemini The problem is that the react-native-sketch-canvas/src/SketchCanvas.js Lines 147 to 153 in b322a86
On iOS it delegates the implementation to a method in the ViewManager. On Android instead it uses a separate Native Module. Calling In an ideal world this library should instead fire a command to save to Base64 that the ViewManager can consume and work on. |
I took a look at a patch for this and I learned that the methods were built differently to workaround getting a value directly from the ViewManager. So the SketchCanvasModule just grabs the view of the SketchCanvas to call a method off it, in order to return it in a callback. Based on @cortinico comment - this probably was not the way to do things. I just struggle to figure out if this plugin was always just abusing a method of development or if it should have always hit a command to view manager for it to emit an event back. Since lets say we make an event/callback on the View manager for like Saving base64 is just getting an output scalar back, so an async nature of making a command and subscribing to an event ( https://github.com/sourcetoad/react-native-sketch-canvas/blob/master/example/src/App.tsx#L317-L328 |
Summary
Hi @terrylinla,
We have identified that this library is not working with the RN new architecture. So we have moved forward with RN 0.72.1 to enable this legacy module with the interop layer and new arch as suggested here -> reactwg/react-native-new-architecture#135
Reproducible sample code -
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
} from 'react-native';
Steps to reproduce
Expected result -
Actual Result -
-Module opens and we are able to add a sketch but then it throws this exception -
React Native Sketch Canvas Version
0.8.0
What platforms are you seeing the problem on?
Android, iOS
React Native Version
0.72.1
What version of Expo are you using?
Not using Expo
Device(s)
iPhone 14 (iOS 16.4) | Android Pixel 5 (API 33)
Additional information
No response
The text was updated successfully, but these errors were encountered: