-
Notifications
You must be signed in to change notification settings - Fork 454
Add support for the Windows OS #182
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
base: master
Are you sure you want to change the base?
Conversation
https://github.com/creambyemute/react-native-sketch-canvas contains this PR + 1 iOS Fix and iOS Memory Leak fixes for anyone interested! |
I've added commits to:
|
@jaimecbernardo Hey, I've just made it to the point where RN-SketchCanvas is used in our project and I think I've found a error/bug for the windows implementation when changing display scale (which is usually not 100% on surface devices) How to reproduce:
If the scale setting is set to 100% it works fine. |
Hi @creambyemute , |
Windows works with Device Independent Pixels already. Don't apply screen scale in JavaScript, as is the case for iOS.
Turns out the JavaScript side was applying a scale according to the pixel ratio, but Windows should work with Device Independent Pixels already. |
@jaimecbernardo Oh great, I'll try it out soon 👍 . |
Hi @terrylinla , |
Hey @jaimecbernardo,
Now to the problem: On Android and iOS we are doing the same and there it is working fine. I guess it's because it's saved inside the How would I move the saved image from Edit: It seems that the windows implementation of react-native-fs crashes when using the
|
Hi @creambyemute , The logic for the module seems to use whatever specific place for images the OS provides, like a Camera Roll, which would be the Pictures library in Windows. The application does seem to have access to the Pictures library, if it's able to save the picture and then run |
@jaimecbernardo Yeah all good. Took me a bit to figure out it was the .exists method from the rn-fs implementation that bugs out. Have a nice week :-) |
@terrylinla any chance of getting this merged or possibly transferring the repo to someone who is willing to maintain it? |
Hey @jaimecbernardo I have been using the branch now for some time and found one odd behaviour on windows that I can replicate when using a localSourceImage/BackgroundImage to draw onto and later on trying to delete the old image. My UseCase is: Take Photo from camera or import image from FilePicker which is then move to appPackage/userFolder. The user can then edit the image and save it, which results in a new image so we'd want to delete the old one. ImageEditor <SketchCanvas
localSourceImage={this.props.localSourceImage} // Image to edit
ref={this.imageEditorRef}
style={styles.imageEditor}
onSketchSaved={this.onImageSaved}
/> onPressSaveImage = () => {
if (this.imageEditorRef.current instanceof SketchCanvas) {
this.imageEditorRef.current.save("jpg", false, "someTmpFolderName", "someTmpFileName", true, false, true);
}
};
onImageSaved = (success: boolean, path: string) => {
if (this.props.onImageSaved && success) {
this.props.onImageSaved(path);
}
}; Parent Component onImageSaved = async (path: string) => {
// Delete the old image (the localSourceImage in this case)
// This step fails when providing localSourceImage although the ImageEditor component has been unmounted
// Move the new image (path) to appPackage/userFolder
}; When I try to delete the old image that was provided as localSourceImage for editing I get an error Any idea what might be going on there? |
Hi @creambyemute, It's possible that One possibility would be to have a memory buffer containing the files contents, though it means using more memory. I'll experiment with that change. |
@jaimecbernardo We're using the same code as outlined above on iOS/Android without any problems cleaning up the old image (localSourceImage) after saving. Haven't looked at the iOS/Android implementation on how they exactly load the provided image, if they dispose it afterwards or create a copy of it to work on. Edit: I had a quick look at the iOS implementation and it seems to create an in-memory copy of the provided localSourceImage. See |
Hi @creambyemute , |
I just tested the change locally and it works. I also checked the memory consumption and it always went down to the initial consumption (before opening SketchCanvas) after saving. Looks good to me! Thx a lot |
Hello @creambyemute / @jaimecbernardo , I found your code from the RNW 0.64 release blog, and am currently attempting to integrate this fork - https://github.com/creambyemute/react-native-sketch-canvas Using the simple SketchCanvas component (since we are building our own UI) and for the most part things seem to work great! However, not having any luck using the getBase64 method to actually extract an image from the canvas. I get the following error returned to the callback parameter / method -
Any help / advice you can provide is much appreciated. Happy to provide any other you may need as well. Thank you in advance! |
Hi @dd-apt , |
@jaimecbernardo thanks for the quick response and your efforts to bring Windows support to this module, much appreciated! |
@jaimecbernardo thanks so much for the quick fix! |
@jaimecbernardo we ran into another issue, although still investigating. Everything works fine locally in the development / debug build, however as soon as we do a release build and get to a screen with the SketchCanvas component, it shows a blank white screen. Our error boundary doesn't seem to catch anything. Was wondering if you are able to reproduce this (x86 Release build), or can provide any direction on tracking down what the issue could be? Thanks again! Update: we were able to get an error, but unsure how helpful it is - |
Hi @dd-apt , Thank you for reporting this. I'll take a better look at this a bit later today or next week. |
@jaimecbernardo ah, yeah we have run into discrepancies between the two engines' behaviors previously, so that would make sense.... Let me know if there's any other information I can provide to help w/ troubleshooting! |
Hi @dd-apt , |
Hi @dd-apt , This seems to have fixed it for my reproduction code so I'll try to modernize this module's JavaScript code. |
Thank you for the update @jaimecbernardo and for looking into the fix, glad to hear you were able to track it down! |
I've opened a new issue for the |
Hi @dd-apt , |
@jaimecbernardo thanks for the heads up! |
Hey @jaimecbernardo I have found another issue regarding the Windows Display Scaling Setting and this time saving an image with rn-sketch-canvas. The problem is, that only a portion (1/4 on 200% scale?) of the backgroundImage (localSourceImage) is included in the saved image and the actual drawing may also not be included (depending on where u draw). It's easily reproducable and I have created a repro example: https://github.com/creambyemute/rnSketchCanvasW10Test How to reproduce:
sketchRef?.save(
'jpg',
false,
'rnSketchTest',
String(Math.ceil(Math.random() * 100000000)),
true,
false,
true // or cropToImageSize false, doesn't matter
);
|
Hi @creambyemute , |
Hi @creambyemute , |
@jaimecbernardo That line fixed it with and without localSourceImage usage. Thanks a lot! |
This pull request adds support for running
react-native-sketch-canvas
onreact-native-windows
.All current features are implemented.
It also adds instructions on how to use it on Windows to the README.