[go: nahoru, domu]

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

expo-brightness restoreSystemBrightnessAsync not working on android #20814

Open
Azuxul opened this issue Jan 12, 2023 · 4 comments
Open

expo-brightness restoreSystemBrightnessAsync not working on android #20814

Azuxul opened this issue Jan 12, 2023 · 4 comments

Comments

@Azuxul
Copy link
Azuxul commented Jan 12, 2023

Summary

When trying to use restoreSystemBrightnessAsync in expo-brightness it dosen't work on android while it is supposed to. The brightness dosen't change and go back to system brightness.

Sometimes i get the following error:

TypeError: _ExpoBrightness.default.restoreSystemBrightnessAsync is not a function. (In '_ExpoBrightness.default.restoreSystemBrightnessAsync()', '_ExpoBrightness.default.restoreSystemBrightnessAsync' is undefined)
http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:226263:72
generatorResume@[native code]
asyncGeneratorStep@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:21012:26
_next@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:21031:29
http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:21036:14
tryCallTwo@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25637:9
doResolve@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25768:25
Promise@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:25656:14
http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:21028:25
restoreSystemBrightnessAsync@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:226256:47

commitHookEffectListMount@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:12634:38
commitPassiveMountOnFiber@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:13656:44
commitPassiveMountEffects_complete@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:13628:40
commitPassiveMountEffects_begin@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:13618:47
commitPassiveMountEffects@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:13608:40
flushPassiveEffectsImpl@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:14837:34
flushPassiveEffects@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:14797:43
http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:14701:34
workLoop@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:61721:48
flushWork@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:61700:28
performWorkUntilDeadline@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:61906:48
http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:26605:26
_callTimer@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:26524:17
_callReactNativeMicrotasksPass@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:26554:17
callReactNativeMicrotasks@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:26717:44
__callReactNativeMicrotasks@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:20150:46
http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:19962:45
__guard@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:20134:15
flushedQueue@http://10.0.0.2:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false:19961:21
flushedQueue@[native code]
callFunctionReturnFlushedQueue@[native code]

I only tested on Redmi Note 10 Pro (Android 12)

What platform(s) does this occur on?

Android

Environment

    expo-env-info 1.0.5 environment info:
    System:
      OS: Windows 10 10.0.19045        
    Binaries:
      Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
      npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: AI-213.7172.25.2113.9123335
    npmPackages:
      @expo/webpack-config: ^0.17.2 => 0.17.3
      expo: ~47.0.8 => 47.0.8
      react: 18.1.0 => 18.1.0
      react-dom: 18.1.0 => 18.1.0
      react-native: 0.70.5 => 0.70.5
      react-native-web: ~0.18.9 => 0.18.10
    Expo Workflow: managed

Minimal reproducible example

https://snack.expo.dev/@geunievre/restoresystembrightnessasync

@Azuxul Azuxul added the needs validation Issue needs to be validated label Jan 12, 2023
@brentvatne brentvatne added needs review Issue is ready to be reviewed by a maintainer Issue accepted Brightness and removed needs validation Issue needs to be validated needs review Issue is ready to be reviewed by a maintainer labels Feb 22, 2023
@expo-bot
Copy link
Collaborator

Thank you for filing this issue!
This comment acknowledges we believe this may be a bug and there’s enough information to investigate it.
However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

@Azuxul
Copy link
Author
Azuxul commented Feb 23, 2023

Any additional information: the function seems to work when the app is built but not in Expo Go, so maybe more an Expo Go problem.

@juliushuck
Copy link

I now have a same error, do not know about production, but in Expo Go on Android when I use await Brightness.restoreSystemBrightnessAsync() I get:

TypeError: undefined is not a function
    at ?anon_0_ (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:165963:72)
    at next (native)
    at asyncGeneratorStep (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20821:26)
    at _next (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20840:29)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20845:14)
    at tryCallTwo (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:61:9)
    at doResolve (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:216:25)
    at Promise (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:82:14)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20837:25)
    at apply (native)
    at _restoreSystemBrightnessAsync (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:165965:47)
    at apply (native)
    at restoreSystemBrightnessAsync (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:165956:47)
    at ?anon_0_ (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:172902:58)
    at next (native)
    at asyncGeneratorStep (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20821:26)
    at _next (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20840:29)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20845:14)
    at tryCallTwo (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:61:9)
    at doResolve (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:216:25)
    at Promise (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:82:14)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20837:25)
    at apply (native)
    at handleUserActivityChangeAsync (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:172911:27)
    at ?anon_0_ (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:172916:38)
    at next (native)
    at asyncGeneratorStep (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20821:26)
    at _next (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20840:29)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20845:14)
    at tryCallTwo (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:61:9)
    at doResolve (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:216:25)
    at Promise (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/2q85j1u4/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:82:14)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:20837:25)
    at apply (native)
    at handleUserInactivityAction (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:172919:27)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:172998:19)
    at commitHookEffectListMount (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:12559:38)
    at commitPassiveMountOnFiber (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:13581:44)
    at commitPassiveMountEffects_complete (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:13553:40)
    at commitPassiveMountEffects_begin (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:13543:47)
    at commitPassiveMountEffects (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:13533:40)
    at flushPassiveEffectsImpl (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:14762:34)
    at flushPassiveEffects (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:14722:43)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:14626:34)
    at workLoop (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:61486:48)
    at flushWork (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:61465:28)
    at performWorkUntilDeadline (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:61671:48)
    at apply (native)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:26304:26)
    at _callTimer (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:26223:17)
    at _callReactNativeMicrotasksPass (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:26253:17)
    at callReactNativeMicrotasks (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:26416:44)
    at __callReactNativeMicrotasks (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:19959:46)
    at anonymous (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:19771:45)
    at __guard (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:19943:15)
    at flushedQueue (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:19770:21)
    at callFunctionReturnFlushedQueue (http://192.168.178.21:19000/source/index.bundle?platform=android&dev=true&hot=false:19755:33)

@nullifier12
Copy link
nullifier12 commented Mar 9, 2023

I have the same problem before , but if you are only using it in a particular page that is being currently rendered and go back to the system brightness if the page is not rendered, I've use useFocusEffect hook from react navigation and useCallback hook and It worked for me, currently I'm running in a expo project and I use it like this.

useFocusEffect( useCallback(() => { const setBrightness = async () => { Brightness.setBrightnessAsync(1); }; setBrightness(); return async () => { Brightness.restoreSystemBrightnessAsync(); }; }, []) );

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

No branches or pull requests

6 participants
@brentvatne @Azuxul @expo-bot @juliushuck @nullifier12 and others