Skip to content

feat: Add fast bytecode mode setting to expert mode#403

Merged
wchill merged 14 commits intodevfrom
add-bytecodeMode
Apr 18, 2026
Merged

feat: Add fast bytecode mode setting to expert mode#403
wchill merged 14 commits intodevfrom
add-bytecodeMode

Conversation

@MarcaDian
Copy link
Copy Markdown
Contributor

No description provided.

wchill and others added 2 commits April 6, 2026 14:25
PatcherProcess: fix process hang when session throws

events.finished(null) was placed after the try/finally block. If Session.run() threw an exception it was caught by CoroutineExceptionHandler but events.finished() was never called, leaving patching.await() in ProcessRuntime hanging indefinitely until the process was killed.

Moved events.finished(null) inside the try block on success, and added a catch block that calls events.finished(stackTrace) on failure, ensuring the main process always receives a completion signal regardless of outcome.

---

CoroutineRuntime: fix MemoryMonitor polling thread leak on early failure

startMemoryPolling() was called before the try block. Any exception thrown before SplitApkPreparer.prepareIfNeeded() — such as from bundles(), PatchBundle.Loader.patches(), or an invalid bundle ID — would skip stopMemoryPolling(), leaving the polling thread running indefinitely.

Wrapped the entire execute() body in an outer try/finally to guarantee stopMemoryPolling() is always called. The inner try/finally for preparation.cleanup() is preserved.

---

PatcherWorker: fix wakelock not released if claimInput throws

wakeLock.acquire() was called before workerRepository.claimInput(). If claimInput() threw an exception the finally block was never reached, holding a partial wakelock for up to 10 minutes.

Moved claimInput() inside the try/finally block using lateinit var args so the wakelock is always released and args remains accessible after the block for the temporary file cleanup check.

PatcherWorker: remove duplicate MemoryMonitor calls

startMemoryPolling() was called in both PatcherWorker and inside CoroutineRuntime.execute(), causing two threads writing concurrently to the same @volatile fields (memoryUsedAverage, memoryUsedMax, memoryPollSamples), producing incorrect memory statistics.

stopMemoryPolling() was also redundantly called in PatcherWorker after already being called inside CoroutineRuntime.execute() and PatcherProcess.

Removed both redundant calls along with the now-unused MemoryMonitor import and usedCoroutineFallback variable. Memory monitor lifecycle is now managed entirely within each runtime implementation.

PatcherWorker: replace restricted API usage with public equivalent

Result.Success type check required @SuppressLint("RestrictedApi") as Result.Success is an internal androidx.work class. Replaced with a patchingSucceeded boolean flag checked against the public Result.success() value, removing the suppression annotation and its import.

PatcherWorker: log warning when temp APK cleanup fails

patchedApk.delete() silently ignored failures. Now logs a warning if the temporary patched APK cannot be deleted and still exists.

---

Session: remove unused nextPatchIndex variable
@wchill
Copy link
Copy Markdown
Contributor

wchill commented Apr 7, 2026

Don't merge until MorpheApp/morphe-patcher#106 is merged

# Conflicts:
#	app/src/main/java/app/morphe/manager/patcher/worker/PatcherWorker.kt
@MarcaDian
Copy link
Copy Markdown
Contributor Author

Can merge?

@LisoUseInAIKyrios

This comment was marked as resolved.

MarcaDian and others added 7 commits April 17, 2026 11:52
# Conflicts:
#	app/src/main/java/app/morphe/manager/domain/manager/PreferencesManager.kt
#	app/src/main/java/app/morphe/manager/patcher/runtime/CoroutineRuntime.kt
#	app/src/main/java/app/morphe/manager/patcher/runtime/ProcessRuntime.kt
#	app/src/main/java/app/morphe/manager/patcher/runtime/process/Parameters.kt
@MarcaDian
Copy link
Copy Markdown
Contributor Author

x86 can be removed

@wchill
Copy link
Copy Markdown
Contributor

wchill commented Apr 17, 2026

@MarcaDian I removed all aapt2 binaries (not only x86) since we don't use aapt2 for packaging anymore.

@MarcaDian
Copy link
Copy Markdown
Contributor Author

Oh, of course, the github app doesn't show it for some reason

Screenshots

Screenshot_2026-04-18-02-51-55-645_com.github.android-edit.jpg

@wchill wchill changed the title feat: Add bytecode mode setting to expert mode feat: Add fast bytecode mode setting to expert mode Apr 18, 2026
@wchill wchill merged commit e73c63c into dev Apr 18, 2026
1 check passed
github-actions bot pushed a commit that referenced this pull request Apr 18, 2026
# [1.16.0-dev.2](v1.16.0-dev.1...v1.16.0-dev.2) (2026-04-18)

### Features

* Add fast bytecode mode setting to expert mode ([#403](#403)) ([e73c63c](e73c63c))
@wchill wchill deleted the add-bytecodeMode branch April 18, 2026 02:15
@LisoUseInAIKyrios LisoUseInAIKyrios linked an issue Apr 18, 2026 that may be closed by this pull request
4 tasks
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.

bug: Patching fails on low end Android 10 and lower devices

3 participants