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

[android] Canvas disappear in Modal when app is resumed from background #2135

Open
Nodonisko opened this issue Jan 12, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Nodonisko
Copy link
Contributor

Description

If you have Canvas inside of RN Modal component and you suspend app to background and then return to your app, Skia Canvas completely disappear. Seems to be Android issue only.

I found out that I can hotfix this by manually triggering rerender of Canvas when AppState change, but it's not idea and there is still visible blink of Canvas.

Video:

screen-20240112-151242.mp4

Version

0.1.233

Steps to reproduce

  1. Open Modal with Skia Canvas
  2. Switch to different app
  3. Switch back to your app => Canvas is gone

Snack, code example, screenshot, or link to a repository

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Modal, View, Button } from "react-native";
import { Canvas, Circle } from "@shopify/react-native-skia";
import React, { useState } from "react";

export default function App() {
  const [isModalVisible, setModalVisible] = useState(false);

  const showModal = () => {
    setModalVisible(true);
  };

  return (
    <View style={styles.container}>
      <Button title="Open Modal" onPress={showModal} />

      <Modal animationType="slide" visible={isModalVisible}>
        <View style={styles.container}>
          <Canvas style={{ flex: 1, width: "100%" }}>
            <Circle r={128} cx={128} cy={128} color="red" />
          </Canvas>
          <Button title="Hide Modal" onPress={() => setModalVisible(false)} />
        </View>
      </Modal>

      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});
@Nodonisko
Copy link
Contributor Author

Hi @wcandillon, I would like to try to fix this one myself, but I am not sure where should I look first. Can give me small hint where to begin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant