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

[SDK 51][Android][Expo Go] Screen orientation change listener not firing #28794

Closed
AdamKronquistToxic opened this issue May 13, 2024 · 0 comments · Fixed by #28832
Closed

[SDK 51][Android][Expo Go] Screen orientation change listener not firing #28794

AdamKronquistToxic opened this issue May 13, 2024 · 0 comments · Fixed by #28832

Comments

@AdamKronquistToxic
Copy link

AdamKronquistToxic commented May 13, 2024

Minimal reproducible example

https://snack.expo.dev/@bycedric/expo-issue-28794

Edit @byCedric: Replaced the default blank template with an actionable repro.

What platform(s) does this occur on?

Android, iOS

Edit @byCedric: Can't repro this for iOS, only Android doesn't seem to fire the screen orientation event listener.

Did you reproduce this issue in a development build?

No (tested in Expo Go)

Summary

After upgrade from expo SDK 50 to 51 my app is no longer working hile testing on Android emulator or iPhone with the Expo Go app. The new version of the Expo Go app forced med to upgrade the SDK to v51.
Width SDK v50 the example works as expected but not width SDK v51.

On my Android emulator the expo-screen-orientation no longer works. I use this code:

import * as ScreenOrientation from "expo-screen-orientation";
  const [orientation, setOrientation] = useState("PORTRAIT");

// Get currect orientation
  const getOrientation = async () => {
    const currentOrientation = await ScreenOrientation.getOrientationAsync();
    if (
      currentOrientation === ScreenOrientation.Orientation.PORTRAIT_UP ||
      currentOrientation === ScreenOrientation.Orientation.PORTRAIT_DOWN
    ) {
      setOrientation("PORTRAIT");
    } else {
      setOrientation("LANDSCAPE");
    }
  };

  // Update orientation
  useEffect(() => {
    getOrientation();

    const subscription = ScreenOrientation.addOrientationChangeListener(
      (event) => {
        if (
          event.orientationInfo.orientation ===
            ScreenOrientation.Orientation.PORTRAIT_UP ||
          event.orientationInfo.orientation ===
            ScreenOrientation.Orientation.PORTRAIT_DOWN
        ) {
          setOrientation("PORTRAIT");
        } else {
          setOrientation("LANDSCAPE");
        }
      }
    );

    return () => {
      ScreenOrientation.removeOrientationChangeListener(subscription);
    };
  }, []);

I used eas update to see if I got the same problem on my iPhone. But on my phone the app crashes when I try to navigate to another screen.

I have run npx expo install --fix to get the recommended version of all packages.

Environment

expo-env-info 1.2.0 environment info:
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: AI-212.5712.43.2112.8609683
npmPackages:
expo: ~51.0.4 => 51.0.4
react: 18.2.0 => 18.2.0
react-native: 0.74.1 => 0.74.1
Expo Workflow: managed

Expo Doctor Diagnostics

✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check native tooling versions
✔ Check dependencies for packages that should not be installed directly
✔ Check for common project setup issues
✔ Check npm/ yarn versions
✔ Check for issues with metro config
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check that native modules do not use incompatible support packages
✔ Check for legacy global CLI installed locally
✔ Check that packages match versions required by installed Expo SDK
✔ Check that native modules use compatible support package versions for installed Expo SDK

Didn't find any issues with the project!

@AdamKronquistToxic AdamKronquistToxic added the needs validation Issue needs to be validated label May 13, 2024
@expo-bot expo-bot added needs review Issue is ready to be reviewed by a maintainer and removed needs validation Issue needs to be validated labels May 13, 2024
@byCedric byCedric changed the title Big problems with SDK 51 (51.0.4) [Android][Expo Go] Screen orientation change listener not firing (51.0.4) May 13, 2024
@byCedric byCedric added Android ScreenOrientation and removed needs review Issue is ready to be reviewed by a maintainer labels May 13, 2024
@byCedric byCedric changed the title [Android][Expo Go] Screen orientation change listener not firing (51.0.4) [SDK 51][Android][Expo Go] Screen orientation change listener not firing (51.0.4) May 13, 2024
@byCedric byCedric changed the title [SDK 51][Android][Expo Go] Screen orientation change listener not firing (51.0.4) [SDK 51][Android][Expo Go] Screen orientation change listener not firing May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants