react-native-view-shot icon indicating copy to clipboard operation
react-native-view-shot copied to clipboard

Capturing two views of different sizes fails randomly (FYI: do not use v2.5 or v2.6)

Open m-pol opened this issue 7 years ago • 5 comments

bug report

Capturing two views of different sizes at or around the same time seems to make one of the resulting images take on the dimensions of the other.

See gif below. There's an orange square view and a purple square view of different sizes. Pressing each button runs captureRef on the corresponding view and displays the generated img next to it.

Version & Platform

├── [email protected]
└── [email protected]

Platform: Android

Expected behavior

In this example, running captureRef on the orange square should always produce an image of size 131x132, and running it on the purple square should always produce 262x262.

Actual behavior

Running captureRef on the orange square sometimes uses the purple square's dimensions, if the purple square has been captured before.

Steps to reproduce the behavior

Clone this repo and run on an Android emulator (or device) to see

git clone https://github.com/m-pol/ReactNativeViewShotBug.git cd ReactNativeViewShotBug npm install react-native run-android

m-pol avatar May 13 '19 00:05 m-pol

2.4.0 doesn't seem to have the issue.

m-pol avatar May 13 '19 19:05 m-pol

have the same problem in v2.6.0. how do you solve it?

EternalChildren avatar Jun 13 '19 01:06 EternalChildren

I think the reason for this problem is cache. it's always happened in multiple captures. And two description about optimized in README. 1.reusable images, that reduce load on GC; 2.reusable arrays/buffers that also reduce load on GC;

tip: just in Android, ios is great. @gre can you help me?

EternalChildren avatar Jun 13 '19 03:06 EternalChildren

@EternalChildren I just reverted to 2.4.0, which does not have the problem.

By the way, #210 is the same issue.

@gre This is a pretty serious issue; it makes the library unusable for anyone trying to use multiple ViewShots. 2.5.0 and 2.6.0 are affected.

m-pol avatar Jun 13 '19 17:06 m-pol

@m-pol I have solved it. PR: #222

EternalChildren avatar Jun 14 '19 01:06 EternalChildren