wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.23k stars 1.92k forks source link

iOS lock screen when App launch or reload #3967

Open aaronpliu opened 1 year ago

aaronpliu commented 1 year ago

Description

The app build with RN bundle. When launch app or reload, the iPhone simulator will be locked. From below log, it run to "Launching com.jumptech.autodev..." then stuck due to screen locked.

2023-03-03T16:18:27.321Z detox DEBUG: i child-process:EXEC_CMD applesimutils --byId C5DFA5C2-E3B3-4AEA-9FD9-08D08A4E15EA --bundle com.jumptech.autodev --restartSB --setPermissions location=always,photos=YES,microphone=YES,notifications=YES
2023-03-03T16:18:27.321Z detox DEBUG: i child-process:EXEC_TRY Trying to set permissions...
2023-03-03T16:18:28.253Z detox DEBUG: i child-process:EXEC_SUCCESS Permissions are set
2023-03-03T16:18:28.266Z detox DEBUG: i child-process:EXEC_CMD /usr/bin/xcrun simctl get_app_container C5DFA5C2-E3B3-4AEA-9FD9-08D08A4E15EA com.jumptech.autodev
2023-03-03T16:18:28.499Z detox DEBUG: i child-process:SPAWN_CMD /usr/bin/xcrun simctl spawn C5DFA5C2-E3B3-4AEA-9FD9-08D08A4E15EA log stream --level debug --style compact --predicate "processImagePath beginsWith \"/Users/Mac/Library/Developer/CoreSimulator/Devices/C5DFA5C2-E3B3-4AEA-9FD9-08D08A4E15EA/data/Containers/Bundle/Application/424072B9-13CE-43BD-BEE5-5B98E9AF60C0/AutoX.app\""
2023-03-03T16:18:28.549Z detox DEBUG: i child-process:EXEC_CMD SIMCTL_CHILD_GULGeneratedClassDisposeDisabled=YES SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/Mac/Library/Detox/ios/37a921ad848a2c15da7c209dcd987654b9223ec0/Detox.framework/Detox" /usr/bin/xcrun simctl launch C5DFA5C2-E3B3-4AEA-9FD9-08D08A4E15EA com.jumptech.autodev --args -detoxServer ws://localhost:51274 -detoxSessionId 9ce300b8-98ad-ee3d-59c1-8691227fd758 -detoxURLBlacklistRegex '("https://clients3.google.com*")' -detoxEnableSynchronization 0 -detoxDisableHierarchyDump YES
2023-03-03T16:18:28.549Z detox DEBUG: i child-process:EXEC_TRY Launching com.jumptech.autodev...
2023-03-03T16:18:33.863Z detox DEBUG: i child-process:EXEC_CMD /usr/bin/xcrun simctl get_app_container C5DFA5C2-E3B3-4AEA-9FD9-08D08A4E15EA com.jumptech.autodev

Your environment

Detox version: 20.1.3 React Native version: 0.64.2 Node version: 16.13 Device model: iPhone 14 Pro OS: 16.2 Test-runner (select one): jest / other

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

lodibrahim commented 1 year ago

I'm also seeing this issue, any update on it?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

aaronpliu commented 1 year ago

seems caused by accessibility inspector. locked screen phenomenon appeared only if inspector open or running. close inspector and restart your Mac it will be resumed. using devtool or xcode to inspect element instead

d4vidi commented 1 year ago

seems caused by accessibility inspector. locked screen phenomenon appeared only if inspector open or running. close inspector and restart your Mac it will be resumed. using devtool or xcode to inspect element instead

@aaronpliu Interesting. Thanks for sharing. Please close the issue if that has resolved things for you.

aaronpliu commented 1 year ago

closed as an alternative way to bypass it. it's still worthing investigating.

d4vidi commented 1 year ago

Please report back with further insights.

IvayloMetodiev commented 1 year ago

up

scyrych commented 1 year ago

up

angelica-snowit commented 1 year ago

I see this problem as well. It seems to happen randomly.

zhouzh1 commented 10 months ago

I'm also facing this weird issue..., is there any more suggestions? @d4vidi

s-chand commented 10 months ago

experiencing this and its causing flakiness

noomorph commented 10 months ago

@asafkorem may I ask you to look here once again?

micahdasMA commented 10 months ago

I'm also experiencing this

MetodievIvaylo commented 9 months ago

It is happening in my project as well. When I run tests in GitHub CI, with 3 workers, 2 are fine but the third simulator is locked.

Seraphiyra commented 9 months ago

I sporadically see this on my nightly CI builds. Not super frequent. Once in a blue moon thing that I haven't been able to find any pattern to.

The machine it is run off of is restarted once per week. It seems irrelevant if it has recently been rebooted (litrally logged in and started a run) or a run midweek, we see might see this happen.

aaronpliu commented 8 months ago

it appears to lock screen from time to time in my current test scripts with Detox v20.16.0 as well

avitretiak commented 8 months ago

I am seeing this too on Detox v20.18.1, xCode 15.3, running scripts locally on iOS simulator

avitretiak commented 5 months ago

Adding to this, could the culprit possibly be --restartSB?

Noticed detox instructs applesimutils to respring iOS when setting permissions (not the case for simctl based permissions), and in my case, this seems to be causing the lockscreen to pop-up.

Removing the respring by patching detox seems to have worked to remediate this so far, but there's probably a reason why we are respringing, haven't found any differences in functionality so far however.

For reference: /src/devices/common/drivers/ios/tools/AppleSimUtils.js

   async setPermissionWithAppleSimUtils(udid, bundleId, service, value) {
     const options = {
-      args: `--byId ${udid} --bundle ${bundleId} --restartSB --setPermissions ${service}=${value}`,
+      args: `--byId ${udid} --bundle ${bundleId} --setPermissions ${service}=${value}`,
       statusLogs: {
         trying: `Trying to set permissions with AppleSimUtils: ${service}=${value}...`,
         successful: `${service} permissions are set`
didyk commented 4 months ago

the same issue, @avitretiak's patch doesn't help

MadSandwich commented 3 months ago

up

ball-hayden commented 3 months ago

We managed to avoid this by removing permissions: { notifications: 'YES' }.

Worth noting that because of the way Detox injects notifications, this permission isn't required to send notifications to the app from Detox.

ball-hayden commented 3 months ago

My guess is that this is related to setting permissions with AppleSimUtils, so any permissions that require AppleSimUtils could have the same effect.

asafkorem commented 3 months ago

@ball-hayden If that's the situation (with notification permissions via applesimutils), you can work around it (for now) by using our system APIs. Just tap the "Allow" button on the permissions dialog to enable push notifications if necessary. If anyone encounters this issue with the latest Xcode and Detox, please let me know, best if you'll provide a minimal reproduction—I'd be happy to look into it together.

ball-hayden commented 3 months ago

Thanks @asafkorem.

We're not seeing issues at all, now, having removed the permissions request - we don't need it since Detox is bypassing that anyway.

If someone else is seeing this with other permissions, perhaps they can try out @asafkorem's suggestion?