question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Black rectangle when screenshoting the view

See original GitHub issue

Hi @brentvatne ,

I’m currently attempting to recreate this example made with gl-react but with gl-react-native.

Unfortunately I’m getting a black screen. The way my code works is by screenshot-ing the UIView like this:

UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, RCTScreenScale());
[view drawViewHierarchyInRect:view.frame afterScreenUpdates:YES];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// (I also tried with an equivalent code that uses `view.layer renderInContext`)

It works with usual content (like <View/> <Text/> <Image/>) but not with this library <Video/>. Do you know why? Is there any way to fix that?


Screenshot-ing an AVPlayer seems to be possible like this: http://stackoverflow.com/a/12415177/343892

But I’m trying to find a generic solution that works with any UIView so I don’t have to explicitly depends on RCTVideo to “cast” the UIView.

EDIT: ultimately I will have to dig into this, if I want to improve perfs of this. I’ve seen this stuff too: https://developer.apple.com/library/ios/samplecode/AVBasicVideoOutput/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013109 . I wish there where a “generic” way to handle this. (can we do duck typing in ObjC? 😄 )


Thanks

EDIT: related http://stackoverflow.com/questions/23286252/screenshot-for-avplayer-and-video

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
shahen94commented, Nov 8, 2016

plus Infinity 👍

1reaction
grecommented, Feb 22, 2017

as the (now) author of react-native-view-shot it would be great if we can find a generic solution to this problem (not saying it’s possible, but would be ideal). We have apparently found a generic solution that should (not sure) work for Android as commented in https://github.com/gre/react-native-view-shot/issues/36 (in Android, some views like opengl backed view provided via react-native-map or some other view like a webview tends to render transparent black/white instead of the actual content – same happens in iOS, but not sure about if there is a generic solution).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix screenshots appear black on Windows 10
Screenshots appear black on Windows 10 (FIX) ; Open Notepad and use the Win+PrntScrn keyboard to capture it. Open your user folder, go...
Read more >
Screenshot leaves a permanent black borde…
When using Command + Shift + 5 and choosing the 'Capture Selected Portion' option on the bar that appears and clicking the Capture...
Read more >
Taking a screenshot of chart view renders black rectangle
to take a screenshot of the whole scroll view (render it as a UIImage). All charts are rendered as black rectangles. Same thing...
Read more >
Snipping Tool Black Screenshot When Trying To Capture (Fix)
When trying to capture a screenshot with Windows 10 built in Snipping Tool, every print screen or capture returns a black screenshot.
Read more >
WC7 - Screen Capture gives me a black box
I just grabbed the screenshot after I created the shot and confirmed shot properties shows the same as the initial pop up. There's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found