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

Crash SkSurface::getCanvas in android 10(Q) #9067

Closed
Zestpond opened this issue Nov 15, 2020 · 22 comments
Closed

Crash SkSurface::getCanvas in android 10(Q) #9067

Zestpond opened this issue Nov 15, 2020 · 22 comments
Labels

Comments

@Zestpond
Copy link

Zestpond commented Nov 15, 2020

App have been crash in android 10. Errors bellow.

============Error===============================
OS Version: Android 10 (QP1A.190711.020.T720XXU1CTI1)
Report Version: 104

Exception Type: Unknown (SIGSEGV)

Application Specific Information:
Segfault

Thread 0 Crashed:
0 libhwui.so 0x77964783c4 SkSurface::getCanvas
1 libhwui.so 0x77963dd258 + 513621742168
2 libhwui.so 0x77965cf900 SkCanvas::onDrawDrawable
3 libhwui.so 0x779644ebf0 + 513622207472
4 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
5 libhwui.so 0x779644ebf0 + 513622207472
6 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
7 libhwui.so 0x779644ebf0 + 513622207472
8 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
9 libhwui.so 0x779644ebf0 + 513622207472
10 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
11 libhwui.so 0x779644ebf0 + 513622207472
12 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
13 libhwui.so 0x779644ebf0 + 513622207472
14 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
15 libhwui.so 0x779644ebf0 + 513622207472
16 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
17 libhwui.so 0x779644ebf0 + 513622207472
18 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
19 libhwui.so 0x779644ebf0 + 513622207472
20 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
21 libhwui.so 0x779644ebf0 + 513622207472
22 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
23 libhwui.so 0x779644ebf0 + 513622207472
24 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
25 libhwui.so 0x779644ebf0 + 513622207472
26 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
27 libhwui.so 0x779644ebf0 + 513622207472
28 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
29 libhwui.so 0x779644ebf0 + 513622207472
30 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
31 libhwui.so 0x779644ebf0 + 513622207472
32 libhwui.so 0x77965cf89c SkCanvas::onDrawDrawable
33 libhwui.so 0x7796454bd4 + 513622232020
34 libhwui.so 0x77964545e8 + 513622230504
35 libhwui.so 0x779647aaec + 513622387436
36 libhwui.so 0x7796477ed0 + 513622376144
37 libhwui.so 0x7796477b3c + 513622375228
38 libhwui.so 0x77964d42e4 + 513622754020
39 libhwui.so 0x77964d3450 + 513622750288
40 libhwui.so 0x77964dea24 + 513622796836
41 libhwui.so 0x77964de70c + 513622796044
42 libutils.so 0x77969dc628 android::Thread::_threadLoop
43 libc.so 0x77944c1f24 + 513589124900
44 libc.so 0x77944600cc + 513588723916
45 0x0

Your Environment

software version
iOS or Android
@react-navigation/native 5.8.9
@react-navigation/stack 5.12.6
react-native 0.63.3

ps: After I force using version worked and no crash! version bellow

software version
iOS or Android
@react-navigation/native 5.7.6
@react-navigation/stack 5.9.2
react-native 0.63.3
@Zestpond Zestpond added the bug label Nov 15, 2020
@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 5.7.6, latest: 5.8.9)
  • @react-navigation/stack (found: 5.9.2, latest: 5.12.6)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@sergeykimaia
Copy link

sergeykimaia commented Nov 16, 2020

happens to me aswell, works fine on android 9, 7.1.1, but crashes on android 10
happened when navigating from one stack to another that has initalRoute

disabling hardware acceleration fixes it for me.

@satya164
Copy link
Member

Can you provide a more info about your Android Device model and repro code? Can you repro the issue if you change the animation using screenOptions={{ cardStyleInterpolator: CardStyleInterpolators .forRevealFromBottomAndroid }}?

@sergeykimaia
Copy link

Can you provide a more info about your Android Device model and repro code? Can you repro the issue if you change the animation using screenOptions={{ cardStyleInterpolator: CardStyleInterpolators .forRevealFromBottomAndroid }}?

adding it to the first stack fixed the crash for me

@satya164
Copy link
Member

@sergeykimaia can you mention your device model please? if it's a device specific issue, we could add a conditional for that model

@sergeykimaia
Copy link

@satya164 i ran it on an emulator Pixel_2_API_29

@satya164
Copy link
Member

are you using react-native-webview?

@sergeykimaia
Copy link

@satya164 yes

@satya164
Copy link
Member

can you also try adding androidHardwareAccelerationDisabled prop on the WebView and removing the animation code above and let me know if the crash still happens?

@sergeykimaia
Copy link

sergeykimaia commented Nov 16, 2020

can you also try adding androidHardwareAccelerationDisabled prop on the WebView and removing the animation code above and let me know if the crash still happens?

@satya164 crash no longer happens.

@satya164
Copy link
Member

thanks! I'll add the workaround to troubleshooting docs and talk to webview maintainers to figure something out to avoid it.

@WoLewicki
Copy link
Member

@sergeykimaia can you check what version of react-native-screens are you using? And do you have enableScreens() called somewhere in your App?

@sergeykimaia
Copy link

@WoLewicki
react-native-screens version: 2.15.0
never called enableScreens()

@WoLewicki
Copy link
Member

@sergeykimaia can you check your index.js file? enableScreens can be added there in some project templates and you can use it without your knowledge.

@sergeykimaia
Copy link

@WoLewicki checked, haven't used it anywhere.

@WoLewicki
Copy link
Member

Ok, thank you.

@StanislavMayorov
Copy link

StanislavMayorov commented Dec 9, 2020

I face the same crash on android 9 and 10 when I navigate from screen with webview. @satya164 do you need a repo to reproduce this bug?
Environment

"@react-navigation/native": "5.7.6",
"@react-navigation/stack": "5.9.2",
"react-native": "0.63.2",
"react-native-webview": "8.1.2",

I use this workaround to hide a webview before animation starts because we need androidHardwareAccelerationDisabled=false.

const Wrapper = (props) => {
  const navigation = useNavigation()
  const [isShowWebview, setShowWebview] = useState(true)

  useEffect(
    () => return navigation.addListener('beforeRemove', (e) => {
        setShowWebview(false)
      }),
    [navigation]
  );

  useEffect(
    () => return navigation.addListener('focus', (e) => {
        setShowWebview(true)
      }),
    [navigation]
  );

  if (isShowWebview){
    return <ComponentWithWebview {...props}/>
  }
  return null
}

@z0al
Copy link

z0al commented Jan 4, 2021

I got the same behavior but in a slightly different setup. Posting here in case it helps someone else. Note that my code is basically copied from the Formidable's Autoheight WebView example & I'm using react-native-screens/native-stack

Environment

"@formidable-webview/webshell": "^2.2.0",
"@react-navigation/native": "^5.8.10",
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
"react-native-webview": "11.0.0",
"react-native-screens": "~2.15.0"

Things I tried

  1. Setting androidHardwareAccelerationDisabled as suggested above: No crash but the WebView is rendered blank for some reason.
  2. Setting stackAnimation on the Screen embedding the WebView to none: No crash. Works just fine. No need to set androidHardwareAccelerationDisabled.
  3. Finally I did try to set an initialHeight for the WebView like this
const window = useWindowDimensions();

const { autoheightWebshellProps } = useAutoheight({
	webshellProps: {
		// ... props
	} ,
        // THIS IS WHAT MATTERS. It works even if you set it to '1' but you will
        // get a small screen flash so try to set it to a reasonable number.
        // One way to fix that is to set a fixed `width` below if it's possible or 
        // set resetHeightOnViewportWidthChange to true. 
        // See: https://formidable-webview.github.io/webshell/docs/api/interfaces/autoheightparams
	initialHeight: window.height,  
});

return (
	<ScrollView
		{...scrollViewProps}
	>
		<WebShell {...autoheightWebshellProps} />
	</ScrollView>
);

This option solved all of the issues. Again, no need to set androidHardwareAccelerationDisabled or disable stack animation. I don't know if it will work for everyone but doesn't hurt giving it a try if your setup is similar.

@1Jesper1
Copy link

1Jesper1 commented Sep 3, 2021

Hello @satya164 Setting cardStyleInterpolator: CardStyleInterpolators.forRevealFromBottomAndroid, worked! Could you add it to the troubleshooting docs please?

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

@1Jesper1
Copy link

1Jesper1 commented Oct 1, 2021

It seems the fix cardStyleInterpolator: CardStyleInterpolators.forRevealFromBottomAndroid did not work for all Android devices.
This #9061 (comment) fixes it for IOS and Android devices.
When does this problem get fixed?

@borra27
Copy link

borra27 commented Nov 19, 2021

import { TransitionPresets } from '@react-navigation/stack';
const transitionPresets = Platform.OS === 'android' ? TransitionPresets.FadeFromBottomAndroid : {};

<Stack.Screen options={{......transitionPresets}} />

I did this and it didn't crash.
I only set it for Android because it only crashed on Android.

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

No branches or pull requests

8 participants