Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

"Cannot Connect to App Store": the request for content is never sent, and nothing network fails

vcvkk58329e8e41ec
diff --git a/README.md b/README.md
index f425a4a..4a392e2 100644
--- a/README.md
+++ b/README.md
@@ -2119,6 +2119,16 @@ std::make_exception_ptr<std::future_error>
**Today, Games, Apps, Arcade, Search**, выбрана Today. Это JetEngine, рисующий тот самый документ,
который мы видели приходящим целиком. Содержимое вкладки Today на этом снимке ещё грузится.
+**Дальше магазин говорит, чего ему не хватает, сам:** после онбординга он рисует свою панель вкладок и
+показывает в теле **«Cannot Connect to App Store»** с кнопкой Retry (`docs/appstore-cannot-connect.png`).
+И это не сеть. В таблице задач по-прежнему те же пять запросов (мешок трижды, `jetpack` дважды), а
+среди всех ошибок, которые приложение создаёт за сеанс, **нет ни одной из `NSURLErrorDomain`** — то
+есть ничего сетевого не падало, запрос за содержимым просто не делается. Что приложение создаёт:
+`AMSErrorDomain` 204 (значения нет в мешке) — 114 раз, `AMSErrorDomain` 7 — 20, 1 — 18, 3 — 10, 300 — 6,
+`AMSSQLiteErrorDomain` 1 — 16, `NSCocoaErrorDomain` 4099 (XPC-соединение оборвано) — 24, 260 — 10,
+`NSPOSIXErrorDomain` 2 — 14, `com.apple.AppSSO.AuthorizationError` −1000 — 4. Ненайденных служб у
+`AppStore` и `appstored` при этом нет ни одной.
+
И отсюда объяснение прежней загадки: **за содержимым не ходили потому, что приложение стояло на
первом экране приветствия** и ждало нажатия, а не потому, что что-то сломано. Прогоны до этого
нажимали на иконку и смотрели на «LOADING», не понимая, что под ним — карточка, ожидающая ответа.
diff --git a/docs/appstore-cannot-connect.png b/docs/appstore-cannot-connect.png
new file mode 100644
index 0000000..25b8f85
Binary files /dev/null and b/docs/appstore-cannot-connect.png differ
diff --git a/userland/rc.jobs.store b/userland/rc.jobs.store
index 588ecd2..827b5aa 100644
--- a/userland/rc.jobs.store
+++ b/userland/rc.jobs.store
@@ -57,6 +57,8 @@
# ... and the welcome card is only the first of the onboarding: after "Continue" comes the choice
# about personalised ads, and "Turn Off" is the honest answer for a phone with no account at all.
/redwood/bin/rwtouch tap 0.5 0.895 wait 25
-/redwood/bin/rwtouch tap 0.5 0.962 wait 95
+# ... and then simply wait, with the report ticking every fifteen seconds: whatever the Today tab
+# asks for after onboarding shows up in the task table with its status, length and type.
+/redwood/bin/rwtouch tap 0.5 0.962 wait 200
/bin/ps -A
/redwood/bin/rwtouch button home wait 6
diff --git a/userland/src/inject_store.c b/userland/src/inject_store.c
index 2fc2fc2..a5101cc 100644
--- a/userland/src/inject_store.c
+++ b/userland/src/inject_store.c
@@ -751,6 +751,77 @@ new_postNotification(id self, SEL cmd, id note)
return old_postNotification(self, cmd, note);
}
+/*
+ * EVERY ERROR THE STORE MAKES, by domain and code, in a table that repeats. After onboarding the
+ * App Store draws its own tab bar and then says "Cannot Connect to App Store" with a Retry button
+ * (docs/appstore-cannot-connect.png) -- and the task table still shows the same five requests, so
+ * whatever it could not connect to was never asked for. The app knows something we do not, and it
+ * knows it as an NSError: this remembers the domain and code of every one made in the process, with
+ * a count, and prints them in each report. Nothing of the userInfo is printed -- that is where
+ * tokens and account details live, and this library is going to run with an Apple ID signed in one
+ * day.
+ */
+#define ERRORS 64
+static struct error_note {
+ char domain[48];
+ long code;
+ unsigned count;
+} errors[ERRORS];
+static unsigned error_count;
+static pthread_mutex_t error_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static void
+note_error(id domain, long code)
+{
+ char text[48];
+
+ if (domain == NULL) {
+ return;
+ }
+ text_of(domain, text, sizeof(text));
+ pthread_mutex_lock(&error_lock);
+ for (unsigned i = 0; i < error_count; i++) {
+ if (errors[i].code == code && strncmp(errors[i].domain, text, sizeof(errors[0].domain) - 1) == 0) {
+ errors[i].count++;
+ pthread_mutex_unlock(&error_lock);
+ return;
+ }
+ }
+ if (error_count < ERRORS) {
+ strlcpy(errors[error_count].domain, text, sizeof(errors[0].domain));
+ errors[error_count].code = code;
+ errors[error_count].count = 1;
+ error_count++;
+ }
+ pthread_mutex_unlock(&error_lock);
+}
+
+static void
+dump_errors(void)
+{
+ say("redwood: store: %u kinds of error made\n", error_count);
+ for (unsigned i = 0; i < error_count; i++) {
+ say("redwood: store: error %-40s code %ld, %u time(s)\n", errors[i].domain, errors[i].code,
+ errors[i].count);
+ }
+}
+
+static id (*old_errorWith)(id, SEL, void *, long, void *);
+static id
+new_errorWith(id self, SEL cmd, void *domain, long code, void *info)
+{
+ note_error((id)domain, code);
+ return old_errorWith(self, cmd, domain, code, info);
+}
+
+static id (*old_errorInit)(id, SEL, void *, long, void *);
+static id
+new_errorInit(id self, SEL cmd, void *domain, long code, void *info)
+{
+ note_error((id)domain, code);
+ return old_errorInit(self, cmd, domain, code, info);
+}
+
/*
* THE SIXTH SHAPE OF AN INSTRUMENT THAT LIES: THE WRONG SLICE. The loader's log keeps the first
* 256 KB and the last 1 MB and throws away the middle when a run overruns it, saying so in one line
@@ -1242,6 +1313,7 @@ one_report(unsigned seconds)
dump_promises();
dump_tasks();
dump_bagkeys();
+ dump_errors();
dump_threads();
/* the long dumps once; the numbers in every report, because only a late one survives the log */
if (first) {
@@ -1666,6 +1738,8 @@ static struct replacement replacements[] = {
(IMP *)&old_dataTaskSignpost, false },
{ "AMSURLSession", "dataTaskWithRequest:completionHandler:", false, (IMP)new_dataTaskAMS,
(IMP *)&old_dataTaskAMS, false },
+ { "NSError", "errorWithDomain:code:userInfo:", true, (IMP)new_errorWith, (IMP *)&old_errorWith, false },
+ { "NSError", "initWithDomain:code:userInfo:", false, (IMP)new_errorInit, (IMP *)&old_errorInit, false },
{ "NSURLSessionTask", "resume", false, (IMP)new_resume_base, (IMP *)&old_resume_base, false },
{ "__NSCFLocalSessionTask", "resume", false, (IMP)new_resume_local, (IMP *)&old_resume_local, false },
};