Skip to content

Commit d96692c

Browse files
authored
Merge pull request #4425 from Otzaria/y-ploni/webview-4120-actual-app-quiet
תוספים ב־Apple: בדיקת פעילות, השהיה ורקע במארחי האפליקציה האמיתיים
2 parents 2a76bf1 + b3b3ebf commit d96692c

20 files changed

Lines changed: 6252 additions & 6 deletions
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Apple installed plugin activity
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- '.github/workflows/apple-plugin-activity.yml'
8+
- 'integration_test/apple_plugin_activity_probe_test.dart'
9+
- 'integration_test/support/apple_plugin_activity_fixture.dart'
10+
- 'integration_test/support/installed_plugin_completion.dart'
11+
- 'integration_test/support/perf_fixture.dart'
12+
- 'integration_test/support/webview_probe_window.dart'
13+
- 'test_driver/apple_plugin_activity.dart'
14+
- 'tool/perf_probe/apple_plugin_activity/**'
15+
- 'test/tool/perf_probe/apple_plugin_activity_contract_test.dart'
16+
- 'test/tool/perf_probe/apple_plugin_activity_completion_test.dart'
17+
- 'test/tool/perf_probe/installed_plugin_completion_test.dart'
18+
- 'test/tool/perf_probe/perf_fixture_test.dart'
19+
- 'test/tool/perf_probe/perf_fixture_startup_settings_test.dart'
20+
- 'lib/app_scope/external_activation_service.dart'
21+
- 'test/app_scope/external_activation_service_test.dart'
22+
- 'lib/plugins/**'
23+
- 'pubspec.yaml'
24+
- 'pubspec.lock'
25+
26+
permissions:
27+
contents: read
28+
29+
concurrency:
30+
group: apple-plugin-activity-${{ github.event.pull_request.number || github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
contracts:
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 30
37+
steps:
38+
- uses: actions/checkout@v7.0.1
39+
- uses: subosito/flutter-action@v2
40+
with:
41+
flutter-version: 3.47.7
42+
channel: stable
43+
cache: true
44+
- uses: dtolnay/rust-toolchain@stable
45+
- name: Native source fallback prerequisites
46+
run: sudo apt-get update && sudo apt-get install -y libclang-dev
47+
- name: Resolve exact dependencies
48+
run: flutter pub get --enforce-lockfile
49+
- name: Counter, identity and boundary controls
50+
run: |
51+
set -euo pipefail
52+
node --test tool/perf_probe/apple_plugin_activity/test_fixture.mjs
53+
python3 -m unittest discover -s tool/perf_probe/apple_plugin_activity -p 'test_*.py' -v
54+
ruby -c tool/perf_probe/apple_plugin_activity/create_control_project.rb
55+
flutter test --no-pub \
56+
test/tool/perf_probe/apple_plugin_activity_contract_test.dart \
57+
test/tool/perf_probe/apple_plugin_activity_completion_test.dart \
58+
test/tool/perf_probe/installed_plugin_completion_test.dart \
59+
test/tool/perf_probe/perf_fixture_test.dart \
60+
test/tool/perf_probe/perf_fixture_startup_settings_test.dart \
61+
test/app_scope/external_activation_service_test.dart \
62+
test/core/external_activation_channel_test.dart \
63+
test/core/external_activation_queue_test.dart
64+
65+
actual-app:
66+
name: Actual app (${{ matrix.platform }} ${{ matrix.mode }})
67+
runs-on: macos-latest
68+
timeout-minutes: 75
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
include:
73+
- platform: macos
74+
mode: profile
75+
- platform: ios
76+
mode: debug
77+
steps:
78+
- name: Reserve time for cleanup and evidence
79+
run: |
80+
python3 - <<'PY'
81+
import os, time
82+
with open(os.environ['GITHUB_ENV'], 'a') as stream:
83+
stream.write(f'APPLE_PROBE_DEADLINE_MONOTONIC={time.monotonic() + 65 * 60}\n')
84+
PY
85+
- uses: actions/checkout@v7.0.1
86+
- uses: subosito/flutter-action@v2
87+
with:
88+
flutter-version: 3.47.7
89+
channel: stable
90+
cache: false
91+
- uses: dtolnay/rust-toolchain@stable
92+
- name: Native iOS Simulator source targets
93+
if: matrix.platform == 'ios'
94+
run: rustup target add aarch64-apple-ios-sim x86_64-apple-ios
95+
- name: Resolve exact dependencies
96+
run: flutter pub get --enforce-lockfile
97+
- name: Select actual runtime
98+
id: runtime_selection
99+
env:
100+
PROBE_PLATFORM: ${{ matrix.platform }}
101+
run: |
102+
set -euo pipefail
103+
if [ "$PROBE_PLATFORM" = macos ]; then
104+
echo 'APPLE_PROBE_DEVICE=macos' >> "$GITHUB_ENV"
105+
else
106+
ruby -e 'require "xcodeproj"'
107+
xcrun simctl list devices available --json > "$RUNNER_TEMP/apple-devices.json"
108+
python3 - <<'PY'
109+
import json, os, subprocess
110+
from pathlib import Path
111+
data = json.loads(Path(os.environ['RUNNER_TEMP'], 'apple-devices.json').read_text())
112+
candidates = [d for runtime, devices in data['devices'].items() if '.iOS-' in runtime
113+
for d in devices if d['name'].startswith('iPhone') and d.get('isAvailable', True)]
114+
if not candidates:
115+
raise SystemExit('No available iPhone simulator; do not substitute a fake background transition')
116+
device = next((d for d in candidates if d['state'] == 'Booted'), candidates[0])
117+
if device['state'] != 'Booted':
118+
subprocess.run(['xcrun', 'simctl', 'boot', device['udid']], check=True)
119+
subprocess.run(['xcrun', 'simctl', 'bootstatus', device['udid'], '-b'], check=True)
120+
with open(os.environ['GITHUB_ENV'], 'a') as stream:
121+
stream.write('APPLE_PROBE_DEVICE=' + device['udid'] + '\n')
122+
PY
123+
open -a Simulator
124+
fi
125+
- name: Verify public identity and diagnose native macOS hide
126+
id: mac_controls
127+
if: matrix.platform == 'macos'
128+
env:
129+
APPLE_HELPER_CONTROL_OUTPUT: ${{ runner.temp }}/apple-helper-controls
130+
run: python3 -m unittest discover -s tool/perf_probe/apple_plugin_activity -p 'test_macos_controller.py' -v
131+
- name: Run installed app hosts and quiet OS transitions
132+
# Collect product evidence after a helper-control failure; that failure remains fatal to this job.
133+
if: ${{ !cancelled() && (success() || (matrix.platform == 'macos' && steps.runtime_selection.outcome == 'success' && steps.mac_controls.outcome == 'failure')) }}
134+
run: >-
135+
python3 tool/perf_probe/apple_plugin_activity/run.py
136+
--platform '${{ matrix.platform }}' --mode '${{ matrix.mode }}'
137+
--device "$APPLE_PROBE_DEVICE" --seconds 12
138+
--output '${{ runner.temp }}/apple-plugin-activity'
139+
- name: Preserve completed and partial evidence
140+
if: always()
141+
uses: actions/upload-artifact@v7.0.2
142+
with:
143+
name: apple-plugin-activity-${{ matrix.platform }}-${{ matrix.mode }}
144+
path: |
145+
${{ runner.temp }}/apple-plugin-activity/*.json
146+
${{ runner.temp }}/apple-plugin-activity/*.log
147+
${{ runner.temp }}/apple-plugin-activity/control/*.swift
148+
${{ runner.temp }}/apple-plugin-activity/control/Control.xcodeproj
149+
${{ runner.temp }}/apple-plugin-activity/control.xcresult
150+
${{ runner.temp }}/apple-helper-controls/*.json
151+
${{ runner.temp }}/apple-helper-controls/*.log
152+
${{ runner.temp }}/apple-helper-controls/*.swift
153+
if-no-files-found: warn
154+
retention-days: 14

‎docs/plugin-sdk/README.md‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ Otzaria.on('plugin.boot', (payload) => {
286286
המופע נשאר בזיכרון. פינוי מופע ושחזורו מתוארים בנפרד בהמשך.
287287
ב-Windows בקשת `TrySuspend` עשויה להידחות; רק תשובת הצלחה מהדפדפן מאשרת
288288
שהמנוע מושהה. ב-Android אוצריא קוראת ל-`WebView.onPause`, שאינו משהה
289-
JavaScript; ב-Linux הדף מסומן מוסתר, וב-macOS וב-iOS אין הקפאה כלל.
289+
JavaScript; ב-Linux הדף מסומן מוסתר. ב-macOS וב-iOS אוצריא אינה מבקשת
290+
הקפאת JavaScript במסלול הזה, אך WebKit ומערכת ההפעלה עדיין עשויים להאט או
291+
להשהות אותו, למשל כשה-WebView מנותק מחלון או כשהאפליקציה ברקע.
290292
**בכל הפלטפורמות התוסף אחראי לעצור polling, timers ועבודה מתמשכת** בעקבות
291293
`plugin.suspended`, שנשלח לפני הבקשה הנייטיבית ואינו אישור להצלחתה.
292294

@@ -317,8 +319,20 @@ Otzaria.on('plugin.resumed', start); // חזרה מהשהיה
317319
Otzaria.on('plugin.suspended', stop); // עצירת timers / polling / WebSocket
318320
```
319321

320-
> 💡 תוסף שרץ ברקע דרך הרשאת `app.run_on_startup` (`runMode: 'background'`) **אינו**
321-
> מושהה — זו בדיוק מטרתו. ההשהיה חלה רק על ה-instance של הלשונית.
322+
> 💡 אוצריא אינה מחילה את מדיניות ההשהיה של הלשונית על מופע עם
323+
> `runMode: 'background'`. זו הבטחה של מנהל המופעים באפליקציה, ולא הבטחה
324+
> ש-WebKit או מערכת ההפעלה יקצו לו זמן ריצה רציף. `startup.keepAlive: true`
325+
> יחד עם הרשאת `app.background_keep_alive` מאושרת מונעים את תפוגת חוסר
326+
> הפעילות של אוצריא; הם אינם מבטלים מגבלות של מערכת ההפעלה או קריסת תהליך תוכן.
327+
328+
ב-iOS 17 וב-macOS 14 ומעלה, Apple מתעדת שמדיניות
329+
[`inactiveSchedulingPolicy`](https://developer.apple.com/documentation/webkit/wkpreferences/inactiveschedulingpolicy-swift.property)
330+
חלה על WebView שאינו בחלון, ושברירת המחדל שלה היא `suspend` בכפוף לחריגים
331+
שהמערכת מגדירה. אוצריא אינה משנה את המדיניות בניסוי
332+
[מדידת הפעילות בתוך מארחי התוספים](../../tool/perf_probe/apple_plugin_activity/README.md).
333+
צילום מצב נייטיבי הוא תיאור של רגע הקריאה; קריאת JavaScript או פקודה אחרי
334+
החזרה אינן הוכחה שהקוד התקדם בזמן הרקע. יש לבדוק את מערכת ההפעלה, גרסת
335+
WebKit, מצב הבנייה והתרחיש הרלוונטיים, ולתכנן חידוש עבודה בטוח.
322336

323337
`plugin.suspended` נמסר לפני בקשת ההשהיה למנוע, כדי שהתוסף יספיק לעצור
324338
polling וטיימרים; הוא אינו אישור שהמנוע הקפיא JavaScript. ב-Windows אוצריא
@@ -881,9 +895,9 @@ Otzaria.on('plugin.boot', async (payload) => {
881895
| אירוע מוצהר + הרשאת רקע מאושרת | WebView נסתר נוצר, `plugin.boot` נורה עם `runMode: 'background'`, ואז האירוע נמסר |
882896
| המשתמש נכנס ללשונית התוסף | **instance נוסף** נוצר (foreground), ה-background נמשך במקביל |
883897
| ההרשאה מבוטלת בהגדרות | ה-instance הרקע נסגר מיידית |
884-
| החלון ממוזער או הלשונית מוסתרת | המופע ממשיך לרוץ — מופע רקע לעולם אינו מושהה ואינו מפונה |
898+
| החלון ממוזער, הלשונית מוסתרת או האפליקציה ברקע | אוצריא אינה מבקשת להשהות את מופע הרקע כחלק ממדיניות הלשוניות; WebKit ומערכת ההפעלה עדיין עשויים להאט או להשהות אותו |
885899
| תהליך הדפדפן שלו נפל | המופע נסגר, והטריגר הבא מעיר אותו. אחרי 3 נפילות ב-10 דקות הוא לא מוער עוד עד ההפעלה הבאה |
886-
| אין פעילות במשך כ-3 דקות | המופע נסגר, אלא אם אושרה הרשאת keep-alive |
900+
| אין פעילות במשך כ-3 דקות | המופע נסגר, אלא אם הוצהר `startup.keepAlive: true` וגם אושרה `app.background_keep_alive`. קריאות SDK ואירועים שנמסרים למופע נחשבים פעילות; התקדמות של טיימר JavaScript מקומי אינה מאריכה את הזמן |
887901
| התוסף מוסר | כל ה-instances נסגרים, כולל מופעים נוספים של כרטיסיות |
888902

889903
---

0 commit comments

Comments
 (0)