Skip to content

feat: Add bytecode mode setting to expert mode#403

Open
MarcaDian wants to merge 6 commits intodevfrom
add-bytecodeMode
Open

feat: Add bytecode mode setting to expert mode#403
MarcaDian wants to merge 6 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
Copy link
Copy Markdown
Contributor

Can wait. There was some issue with patching X

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.

3 participants