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

Cannot take snapshot in real Device, but simulator is fine #44

Closed
gameboyVito opened this issue Mar 7, 2017 · 3 comments
Closed

Cannot take snapshot in real Device, but simulator is fine #44

gameboyVito opened this issue Mar 7, 2017 · 3 comments

Comments

@gameboyVito
Copy link

gameboyVito commented Mar 7, 2017

Hi, I would like to capture my WebView. In the simulator, it works fine, and I can store it to any Dir. However, when I run the code using debug mode or release mode on my device, it always shows the same error. Could you please point out what's wrong here? Thanks.

Here is the error message:

2017-03-07 11:33:35.413 [info][tid:com.facebook.react.JavaScript] { [Error: Failed to capture view snapshot]
  line: 2813,
  column: 24,
  sourceURL: 'file:///var/containers/Bundle/Application/F030ED8C-8964-4991-91A6-6A5AFDFC23A5/Altizure.app/main.jsbundle',
  framesToPop: 1,
  code: 'EUNSPECIFIED',
  nativeStackIOS: 
   [ '0   Altizure                            0x00000001001e0634 RCTJSErrorFromCodeMessageAndNSError + 152',
     '1   Altizure                            0x000000010016a1b4 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.224 + 184',
     '2   Altizure                            0x00000001003a8b74 __54-[RNViewShot takeSnapshot:withOptions:resolve:reject:]_block_invoke + 988',
     '3   Altizure                            0x000000010021c78c __29-[RCTUIManager flushUIBlocks]_block_invoke + 660',
     '4   libdispatch.dylib                   0x00000001008d9258 _dispatch_call_block_and_release + 24',
     '5   libdispatch.dylib                   0x00000001008d9218 _dispatch_client_callout + 16',
     '6   libdispatch.dylib                   0x00000001008de280 _dispatch_main_queue_callback_4CF + 1200',
     '7   CoreFoundation                      0x000000018c2aa810 <redacted> + 12',
     '8   CoreFoundation                      0x000000018c2a83fc <redacted> + 1660',
     '9   CoreFoundation                      0x000000018c1d62b8 CFRunLoopRunSpecific + 444',
     '10  GraphicsServices                    0x000000018dc8a198 GSEventRunModal + 180',
     '11  UIKit                               0x000000019221d7fc <redacted> + 684',
     '12  UIKit                               0x0000000192218534 UIApplicationMain + 208',
     '13  Altizure                            0x00000001000fa144 main + 124',
     '14  libdyld.dylib                       0x000000018b1b95b8 <redacted> + 4' ],
  domain: 'RCTErrorDomain',
  userInfo: null }

Development environment:
Xcode 8.2.1
iOS 10.2
ReactNative 0.42

To reproduce:

async takeSnapshot() {
        try {
            this.snapshot = await takeSnapshot(this.modelContainer, {
                format: "jpeg",
                quality: 0.7,
                path: PictureDir + "/snapshot.jpeg"
            });
            console.log(this.snapshot);
        } catch (err) {
            console.log(err);
        }
    }
<View style={styles.viewer} ref={(ref) => { this.modelContainer = ref; }}>
     <WkWebView
          ref={(ref) => { this.webview = ref; }}
          startInLoadingState={true}
          renderLoading={this.renderLoading}
          source={require('./earth.html')}
          onMessage={(event) => this.shareSheet.earth(event.body, this.snapshot)}
          injectedJavaScript={jsCode}
          javaScriptEnabled={true}
    />
</View>
viewer: {
    flex: 1,
    zIndex: -1,
    backgroundColor: '#232323'
}
@gre
Copy link
Owner

gre commented Mar 7, 2017

you have closed the issue, it's fixed?

@gameboyVito
Copy link
Author

gameboyVito commented Mar 7, 2017

Not yet, but I found it's duplicated to #40.
I guess the reason is my WebView displays content of webGL, and the drawViewHierarchyInRect always throws exceptions due to the webGL.

@gameboyVito
Copy link
Author

gameboyVito commented Mar 7, 2017

0a50658b22e7ac9cb5c8b6f58d0e808d

I have set a breakpoint to see if there is an image that can be captured successfully. It turns out that the process of capturing has some errors. It only captures part of the WebView content, the WebGL content just disappears.

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