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

Rejecting while taking snapshot of "zero height" view #21

Closed
sodik82 opened this issue Nov 12, 2016 · 5 comments
Closed

Rejecting while taking snapshot of "zero height" view #21

sodik82 opened this issue Nov 12, 2016 · 5 comments
Assignees

Comments

@sodik82
Copy link

sodik82 commented Nov 12, 2016

I got following error/rejection:

2016-11-12 13:43:43.339 [info][tid:com.facebook.react.JavaScript] 'Taking snapshot', true
Nov 12 13:43:43  rnSnapshooter[96767] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Nov 12 13:43:43  rnSnapshooter[96767] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2016-11-12 13:43:43.380 [error][tid:com.facebook.react.JavaScript] 'Oops, snapshot failed', { [Error: Failed to capture view snapshot]
  line: 3548,
  column: 20,
  sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false',
  framesToPop: 1,
  code: 'EUNSPECIFIED',
  nativeStackIOS: 
   [ '0   rnSnapshooter                       0x000000010a054ea6 RCTJSErrorFromCodeMessageAndNSError + 134',
     '1   rnSnapshooter                       0x0000000109fd4aa3 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.224 + 147',
     '2   rnSnapshooter                       0x000000010a0fb899 __54-[RNViewShot takeSnapshot:withOptions:resolve:reject:]_block_invoke + 1161',
     '3   rnSnapshooter                       0x000000010a08f4d8 __29-[RCTUIManager flushUIBlocks]_block_invoke + 792',
     '4   libdispatch.dylib                   0x000000010e57fe5d _dispatch_call_block_and_release + 12',
     '5   libdispatch.dylib                   0x000000010e5a049b _dispatch_client_callout + 8',
     '6   libdispatch.dylib                   0x000000010e5882af _dispatch_main_queue_callback_4CF + 1738',
     '7   CoreFoundation                      0x000000010b59bd09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9',
     '8   CoreFoundation                      0x000000010b55d2c9 __CFRunLoopRun + 2073',
     '9   CoreFoundation                      0x000000010b55c828 CFRunLoopRunSpecific + 488',
     '10  GraphicsServices                    0x000000011003cad2 GSEventRunModal + 161',
     '11  UIKit                               0x000000010cf59610 UIApplicationMain + 171',
     '12  rnSnapshooter                       0x0000000109fac8bf main + 111',
     '13  libdyld.dylib                       0x000000010e5d492d start + 1' ],
  domain: 'RCTErrorDomain',
  userInfo: null }

with following view to snapshot:

      <View ref="root" style={{backgroundColor: 'yellow'}}>
        <DemoApp/>
      </View>

everything works with style={{flex:1,backgroundColor: 'yellow'}}. Without the flex I can see DemoApp but I don't see yellow background.

Feel free to close this issue if you don't want to handle such cases. Just wanted to document somewhere my troubles and how to "workaround" them if anyone would come to this problem.

@gre
Copy link
Owner

gre commented Nov 30, 2016

and if you .measure your View, what does it say for height? I don't see how we can support this if it's height=0.

@sodik82
Copy link
Author

sodik82 commented Dec 1, 2016

no, I haven't measure the view. I just assume from (not)visible background color. It is funny that DemoApp is visible (but maybe as a consequence of absolute positioning). But it is RN issue how it handles such cases - which I assume you can't influence.

My point is that you can't capture zero height view correctly - that's true - but to receive EUNSPECIFIED error with such "nasty stacktrace" can be bit confusing. It looks like some edge condition is not properly handled somewhere in native code and handling it with nicer/more meaningful error message would help.

Secondary point was to "document" somewhere the problem and workaround if someone will face the same problem as I had.

@gre
Copy link
Owner

gre commented Dec 1, 2016

I guess it works on iOS, but have you tried on Android? I think Android don't support it; it doesn't support (yet) overflow: visible.

I guess maybe the library should just throw if any of width or height is <=0

@sodik82
Copy link
Author

sodik82 commented Dec 1, 2016

haven't tried it on Android. I just was confused by the error since I used it for the first time and was not sure if something went wrong with linking of native code or what...
but of course I didn't wanted to get snapshot of zero height view - so in the end I fixed it and it started to work :)

@gre gre self-assigned this Feb 28, 2017
@gre gre closed this as completed in 7e7dedc Mar 9, 2017
@sodik82
Copy link
Author

sodik82 commented Mar 9, 2017

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants