Skip to content

PyMobile 0.15.0 - #4

Merged
Maksum867 merged 1 commit into
mainfrom
PyMobile-0.15.0
Nov 14, 2026
Merged

Maksum867 merged 1 commit into
mainfrom
PyMobile-0.15.0

Conversation

@Maksum867

Copy link
Copy Markdown
Owner

Закриває два блокери аудиту (pymobile_audit.md) і все, що було достатньо дешевим, щоб увійти в цей же реліз. Кожен пункт спершу відтворений, потім виправлений, і тримається тестом, який без правки падає.

CI цього PR: прогін 43638276536 — success, усі 9 джоб (Python 3.10–3.15, Windows, Android APK+AAB). Локально: 2509 passed / 47 skipped, ruff і mypy чисто.

Публікація (A10, A1)

  • build --native --bundle пише .aab поруч з APK і перевіряє його bundletool validate + build-apks --mode=universal. Дорогою знайдено три дефекти пакування, яких не бачив жоден юніт-тест: маніфест копіювався бінарним з APK замість proto XmlNode; base/res/ годувався .flat-проміжними файлами; нативні бібліотеки шукалися не в тому каталозі, тому бандл узагалі не містив жодної.
  • target_sdk за замовчуванням 36, setup-sdk ставить platforms;android-36. Шаблон нового проєкту при цьому віддавав 35 — тобто свіжий проєкт усе одно не пройшов би в Play.
  • find_toolchain() компілює проти SDK_PLATFORM, а не target_sdk, тож задекларований і скомпільований рівні не можуть розійтися.
  • Знищення Activity більше не вбиває інтерпретатор: onDestroy шле __lifecycle__/stop, Screen.on_stop() зберігає стан, наступне вікно продовжує той самий застосунок через Screen.on_start(). Події, що прийшли після зупинки, відкидаються.

На пристрої (A2, A3, A4, A5, A9, A18, A19)

  • Кореневий контейнер сам застосовує вставки системних панелей, вирізу й IME; adjustResize плюс подія app:insets закривають клавіатуру.
  • Зображення декодуються в робочому потоці, з масштабуванням під view, EXIF-поворотом і відкиданням результату, що програв гонку новішому джерелу.
  • supportsRtl і marginStart/End — арабська й іврит дзеркаляться.
  • Стартовий екран іде за системною темою; перемикання light/dark доходить до Python як app:system-theme (App(follow_system_theme=True) слідує сам).
  • Back-callback живе лише поки є куди йти; на корені знову працює системний «вихід із застосунку».
  • Три застарілі виклики замінено; віддалене джерело Image попереджає, а не малює порожнечу.

Пакування і безпека (A17, S7)

  • abis = [...] справді пакує кожну архітектуру в один APK — друга раніше відкидалася без слова.
  • [network.pins] пінить домен до вказаних сертифікатів, а заразом перестає довіряти користувацьким CA на пристрої.

Коректність сховища, яку знайшов CI

  • Провалений стан сховища жив лише поки жив об'єкт (реєстр слабкий), тож повторне відкриття файлу мовчки пробувало знову — на Python 3.10 це ловив CI. Тепер провалені стани утримуються на процес, як і обіцяв докстрінг.
  • Тест «1000 puts are quick» міряв секундоміром і падав на спільних і Windows-раннерах, поки код був у порядку. Тепер він рахує записи (однакове число всюди) зі щедрою стелею проти квадратичної регресії, і в батчингу з'явився власний тест.

Для контриб'ютора й новачка (C5, C6, C8, N3, K11)

  • Джоба Android у CI збирає підписаний APK і .aab на кожен push і перевіряє, що маніфест оголошує target 36 і supportsRtl. Її перший прогін зловив пінований SHA екшена, якого не існує.
  • docs/TUTORIAL.md і docs/BEGINNER-MISTAKES.md; імпорти туторіала й усі документовані команди перевіряються тестами, тож перейменування ламає CI, а не першу годину новачка. Папки examples/ у репозиторії немає — приклад це сам туторіал.
  • Storage і ModelStore описують ключі міграцій однаково, і кожне повідомлення про помилку посилається на друге сховище.

Також: --minimal-stdlib прибирає те, що телефону не потрібне (709 → 514 файлів у APK), dex перезібрано й хеші джерел перезаписано.

Чого тут свідомо немає

A11 (точки розширення), A12 (AndroidX/Material), A13 (RecyclerView), A14 (інкрементальні кадри), A6 (.so у lib/) і A7 (.pyc в APK) вимагають перезбірки рантайму або переробки підсистеми; S1 залежить від тієї ж збірки з NDK. F4 і F8 відкладені рішенням власника.

Ніщо з Android-поведінки вище не спостерігалося на фізичному пристрої — доказ це javac проти android-36, bundletool на реальному бандлі й тести. Перший прогін на телефоні може показати розбіжності, і саме тому джоба Android у CI тепер збирає артефакт на кожен push.

The audit's two blockers are closed, plus everything that was cheap enough to
finish in the same release. Every item below was reproduced first, fixed in the
code, and is held by a test that fails without the change.

Publishing (A10, A1)
- `build --native --bundle` writes an `.aab` beside the APK, from the same
  manifest, dex, assets and native libraries, and validates it with bundletool
  (`validate` + `build-apks --mode=universal`). Three packaging defects only
  bundletool could see were fixed on the way: the manifest was copied as binary
  APK bytes instead of a proto XmlNode, `base/res/` was fed the compiler's
  `.flat` intermediates, and native libraries were looked for in the wrong
  directory (so a bundle carried none at all).
- Default `target_sdk` is 36 and `setup-sdk` installs `platforms;android-36`,
  the level Play requires from 31 August 2026. The new-project template still
  said 35, so a fresh project would have been rejected after all of this.
- `find_toolchain()` compiles against `SDK_PLATFORM` rather than `target_sdk`,
  so the compiled level and the declared level cannot disagree.
- A destroyed Activity no longer takes the interpreter with it: `onDestroy`
  sends a `__lifecycle__`/`stop` event, `Screen.on_stop()` runs, widget state is
  kept, and the next window resumes the same app with `Screen.on_start()`.
  Input that arrives after the stop is dropped.

On the device (A2, A3, A4, A5, A9, A18, A19)
- The root container applies system-bar, cutout and IME insets itself;
  `adjustResize` and an `app:insets` event cover the keyboard.
- Images are decoded on a worker thread, scaled to the view, EXIF-rotated, and a
  decode that loses the race against a newer source is discarded.
- `supportsRtl` and start/end margins, so Arabic and Hebrew mirror.
- The startup screen follows the system theme, and a light/dark switch reaches
  Python as `app:system-theme` (`App(follow_system_theme=True)` follows it).
- The back callback is registered only while there is a screen to go back to;
  on the root screen the platform's own "leave the app" runs again.
- Three deprecated calls replaced; a remote `Image` source warns instead of
  drawing an empty box.

Packaging and security (A17, S7)
- `abis = [...]` now really packages every requested architecture in one APK;
  the second one used to be dropped without a word.
- `[network.pins]` pins a domain to the certificates you list, which also stops
  the app trusting the device's user-installed roots.

Storage correctness found by CI
- A store that failed to load stayed failed only while the object happened to
  be alive: the backend registry is weak, so a pinned failure could be
  collected and the next open quietly retried. Failed states are now held for
  the process, which is what the docstring always promised.
- The "1000 puts are quick" test asserted a wall-clock budget and failed on
  shared and Windows runners while the code was fine. It now counts storage
  writes (the same number everywhere) with a generous ceiling that only a
  quadratic regression trips, and the batching promise got its own test.

Contributor and beginner experience (C5, C6, C8, N3, K11)
- An Android CI job builds a signed APK and an `.aab` on every push and asserts
  the manifest declares target 36 and `supportsRtl`. Its first run caught a
  pinned action SHA that does not exist.
- `docs/TUTORIAL.md` and `docs/BEGINNER-MISTAKES.md`; the tutorial's imports and
  every documented command are checked by tests, so a rename breaks CI instead
  of a newcomer's first hour. There is no `examples/` tree: the tutorial is the
  example.
- `Storage` and `ModelStore` describe their migration keys the same way, and
  each error message points at the other store.

Also: `--minimal-stdlib` drops what a phone cannot use (709 -> 514 packaged
files), the bundled dex is rebuilt and its source hashes re-recorded.

Not in this release, and not pretended otherwise: extension points (A11),
AndroidX/Material (A12), RecyclerView (A13), incremental frames (A14),
`.so` under `lib/` (A6) and `.pyc` in the APK (A7) need rebuilding the runtime
or redesigning a subsystem; S1 depends on that same NDK rebuild. None of the
Android behaviour above has been observed on a physical device here - the
evidence is javac against android-36, bundletool on a real bundle, and tests.
@Maksum867
Maksum867 merged commit e9412ba into main Nov 14, 2026
18 checks passed
@Maksum867
Maksum867 deleted the PyMobile-0.15.0 branch November 14, 2026 21:07
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

Successfully merging this pull request may close these issues.

1 participant