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

[snapshot] When setting override_status_bar to true, the time in screenshot is 10:41 instead of 9:41 #22026

Open
4 tasks done
funnel20 opened this issue May 15, 2024 · 1 comment

Comments

@funnel20
Copy link
Contributor

funnel20 commented May 15, 2024

New Issue Checklist

Issue Description

I have added override_status_bar true to the Snapfile. When running snapshot, all screenshots have time stamp "10:41" in the Status Bar. According to the docu (fastlane action capture_screenshots) it should be "9:41":

| override_status  | Enabling this    | SNAPSHOT_OVERRI  | false            |
| _bar             | option will      | DE_STATUS_BAR    |                  |
|                  | automatically    |                  |                  |
|                  | override the     |                  |                  |
|                  | status bar to    |                  |                  |
|                  | show 9:41 AM,    |                  |                  |
|                  | full battery,    |                  |                  |
|                  | and full         |                  |                  |
|                  | reception        |                  |                  |
|                  | (Adjust          |                  |                  |
|                  | 'SNAPSHOT_SIMUL  |                  |                  |
|                  | ATOR_WAIT_FOR_B  |                  |                  |
|                  | OOT_TIMEOUT'     |                  |                  |
|                  | environment      |                  |                  |
|                  | variable if      |                  |                  |
|                  | override status  |                  |                  |
|                  | bar is not       |                  |                  |
|                  | working. Might   |                  |                  |
|                  | be because       |                  |                  |
|                  | simulator is     |                  |                  |
|                  | not fully        |                  |                  |
|                  | booted.          |                  |                  |
|                  | Defaults to 10   |                  |                  |
|                  | seconds)         |                  |                  |

I expect this is related to Summer Time / Day Light Saving. I'm currently in time zone CEST: Central European Summer Time.

Now comes the crazy part; I wanted to manually set the time to 9:41 via override_status_bar_arguments. However, I wasn't aware of the syntax, so I started simple with the --wifiBars, by adding the following to the Snapfile:

override_status_bar true
override_status_bar_arguments "--wifiBars 1"

All of a sudden, not only 1 WiFi bar was shown, but also the screenshot showed "9:41" 🤔
Also tested with "--wifiBars 3" to get the default WiFi bar, and still the time was correct at "9:41" ✅
Removing this line with override_status_bar_arguments, showed the wrong time ❌

Screenshot 2024-05-15 at 11 24 10

💡 So adding override_status_bar_arguments "--wifiBars 3" seems to be a work-around for this issue.

Command executed

Adding property override_status_bar true to the Snapfile results in the wrong time on the screenshot.

Complete output when running fastlane, including the stack trace and command used
 [REPLACE THIS WITH YOUR INFORMATION] 

Environment

✅ fastlane environment ✅

Stack

Key Value
OS 14.4.1
Ruby 2.7.2
Bundler? false
Git git version 2.39.3 (Apple Git-146)
Installation Source ~/.rvm/gems/ruby-2.7.2/bin/fastlane
Host macOS 14.4.1 (23E224)
Ruby Lib Dir ~/.rvm/rubies/ruby-2.7.2/lib
OpenSSL Version OpenSSL 1.1.1k 25 Mar 2021
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 15.3
Swift Version 5.10

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL en_US.UTF-8
LANGUAGE

fastlane files:

No Fastfile found

No Appfile found

fastlane gems

Gem Version Update-Status
fastlane 2.220.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.4.0
executable-hooks 1.6.1
bundler-unload 1.0.2
rubygems-bundler 1.4.5
bundler 2.3.26
artifactory 3.0.15
jmespath 1.4.0
aws-partitions 1.482.0
aws-eventstream 1.1.1
aws-sigv4 1.2.4
aws-sdk-core 3.119.0
aws-sdk-kms 1.46.0
aws-sdk-s3 1.98.0
babosa 1.0.4
colored 1.2
highline 2.0.3
commander 4.6.0
dotenv 2.7.6
emoji_regex 3.2.2
excon 0.85.0
faraday-em_http 1.0.0
faraday-em_synchrony 1.0.0
faraday-excon 1.1.0
faraday-httpclient 1.0.1
faraday-net_http 1.0.1
faraday-net_http_persistent 1.2.0
faraday-patron 1.0.0
faraday-rack 1.0.0
multipart-post 2.0.0
ruby2_keywords 0.0.5
faraday 1.6.0
faraday_middleware 1.1.0
faraday-cookie_jar 0.0.7
fastimage 2.2.4
gh_inspector 1.1.3
uber 0.1.0
declarative 0.0.20
trailblazer-option 0.1.1
representable 3.1.1
retriable 3.1.2
mini_mime 1.1.0
jwt 2.2.3
memoist 0.16.2
multi_json 1.15.0
os 1.1.1
signet 0.15.0
googleauth 0.17.0
httpclient 2.8.3
webrick 1.6.0
google-apis-core 0.4.1
google-apis-androidpublisher_v3 0.10.0
google-apis-playcustomapp_v1 0.5.0
google-cloud-env 1.6.0
google-cloud-errors 1.1.0
google-cloud-core 1.6.0
google-apis-iamcredentials_v1 0.6.0
google-apis-storage_v1 0.6.0
rake 13.0.1
digest-crc 0.6.4
google-cloud-storage 1.34.1
unf_ext 0.0.7.7
unf 0.1.4
domain_name 0.5.20190701
http-cookie 1.0.5
mini_magick 4.11.0
naturally 2.2.1
optparse 0.1.1
plist 3.6.0
rubyzip 2.3.2
security 0.1.5
simctl 1.6.8
terminal-notifier 2.0.0
unicode-display_width 1.7.0
terminal-table 3.0.2
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.1
uri 0.10.0
public_suffix 4.0.7
addressable 2.8.1
rexml 3.2.5
CFPropertyList 3.0.5
json 2.6.2
nanaimo 0.3.0
colored2 3.1.2
claide 1.1.0
atomos 0.1.3
xcodeproj 1.23.0
forwardable 1.3.1
logger 1.4.2
cgi 0.1.0
date 3.0.0
timeout 0.1.0
stringio 0.1.0
ipaddr 1.2.2
openssl 2.1.2
zlib 1.1.0
mutex_m 0.1.0
ostruct 0.2.0
strscan 1.0.3
io-console 0.5.6
delegate 0.1.0
fileutils 1.4.1
singleton 0.1.0
open3 0.1.0
yaml 0.1.0
psych 3.1.0

generated on: 2024-05-15

@funnel20 funnel20 changed the title [snapshot] When setting override_status_bar to true, the time in screenshot is 10:41 instead of 9:41 [snapshot] When setting override_status_bar to true, the time in screenshot is 10:41 instead of 9:41 May 15, 2024
@funnel20
Copy link
Contributor Author

funnel20 commented May 15, 2024

Sorry, this is a duplicate of #21464

However, I figured it out and have a work-around.

Analysis

When using override_status_bar true, the console log shows the automatically generated arguments:

$ xcrun simctl status_bar 463A8557-2F51-432A-A880-7EA671F20805 override --time 2007-01-09T09:41:00+01:00 --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100 &> /dev/null

When adding override_status_bar_arguments "--wifiBars 3", the console log shows:

$ xcrun simctl status_bar 4CD9AAB8-AAF8-461D-B077-7815623A2436 override --wifiBars 3 &> /dev/null

The reason why the latter worked, was because my Simulator was already started with Simulator Status Magic enabled.
Using a brand new Simulator, doesn't show the "9:41", but the current time. This clarifies 1 observation.

So the root cause is in the ISO time stamp for parameter --time: 2007-01-09T09:41:00+01:00.
The time zone +01:00 is wrong, since I'm at CEST which has Daylight Saving enabled, so it's currently +02:00.

Work-around

When manually changing the timezone in the arguments in the Snapfile the correct time is displayed in the screenshots:

override_status_bar_arguments "--time 2007-01-09T09:41:00+02:00 --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100"

However, when running Snapshot in winter, it will display the wrong time. Hence made the time zone offset dynamically in the Snapfile with some Ruby code:

require 'active_support/all'    # For `Time.now.formatted_offset()`

devices([
    "iPhone 12 Pro",
    ])

# Get current timezone offset:
timezone_offset = Time.now.formatted_offset(true)
puts("timezone_offset = #{timezone_offset}")               # Optional, to write to Console output

# Override status bar and override arguments incl. timezone offset, as by default it goes wrong with Daylight Saving Time (e.g. shows "10:41" instead of "9:41", see: https://github.com/fastlane/fastlane/issues/22026 )
override_status_bar true
override_status_bar_arguments "--time 2007-01-09T09:41:00#{timezone_offset} --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100"    # For a list of commands, type the following in Terminal: xcrun simctl status_bar --help

Solution

To resolve this in code, the Time object should get the proper time zone information, see:

# The time needs to be passed as ISO8601 so the simulator formats it correctly
time = Time.new(2007, 1, 9, 9, 41, 0)
# If you don't override the operator name, you'll get "Carrier" in the status bar on no-notch devices such as iPhone 8. Pass an empty string to blank it out.
arguments = "--time #{time.iso8601} --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100"

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

No branches or pull requests

1 participant