Repository navigation
Conversation
Both crop paths signalled an unusable source with `?: throw Error(...)`.
`kotlin.Error` maps to `java.lang.Error`, which is not an `Exception`, so
the throw slipped past the only guard around the crop work
(`catch (e: Exception)`) and escaped `moduleCoroutineScope.launch { }` —
a bare `CoroutineScope(Dispatchers.Default)` with no
CoroutineExceptionHandler. It reached the thread's uncaught handler, so
the app crashed and the promise never settled.
`BitmapRegionDecoder.newInstance` returns null for anything it can't
decode, so this is easy to hit: a non-image URL (`cropImage(url)` on a
PDF, or a server returning an HTML error page with HTTP 200), or a
GIF/HEIC/corrupt file. iOS and web reject for the same input.
`OutOfMemoryError` while decoding large images escaped the same way.
Throw `JSApplicationIllegalArgumentException`, which the JS layer already
surfaces as a normal rejection, and widen the guard to `Throwable` so
errors become rejections too.
This was referenced Dec 2, 2026
retyui
added a commit
that referenced
this pull request
Dec 3, 2026
…er invalidate A crop job never suspends, so cancelling the scope in `invalidate()` doesn't stop it: it went on to write its file after the cache cleanup had run, and that file stayed until the next launch. Skip writing once invalidated, and delete the file if invalidation claimed the promise while it was written. Build the result map before claiming the promise, so a failure there (e.g. reading the file back for `includeBase64`) is still rejected instead of leaving the promise unsettled. Catch `Throwable` rather than `Exception`: an `Error` (OutOfMemoryError, or the `throw Error` on a null decoder) escaped `settleOnce` and left the promise pending. This overlaps #224, which makes the same change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
K1: crash.
?: throw Error(...)is replaced withJSApplicationIllegalArgumentException, andcatch (Exception)withcatch (Throwable).kotlin.Errorisjava.lang.Error, which is not anException. So?: throw Error("Could not create bitmap decoder…")went straight throughcatch (e: Exception)into a bareCoroutineScope(Dispatchers.Default)with noCoroutineExceptionHandler. The result was a process crash, and the promise never settled.Repro:
cropImage('https://…/report.pdf'), a GIF/HEIC, or a server that returns an HTML error page with HTTP 200.BitmapRegionDecoder.newInstancereturns null and the app crashes. iOS and web reject for the same input. AnOutOfMemoryErrorfromdecodeRegionescaped the same way.Promise.reject(Throwable)(1-arg) exists in the 0.79.5 and 0.87.1 AARs. The 2-argreject(String, String)would not accept anError.Verification
Not compiled. No
:android:compileDebugKotlinrun and nothing run on a device. The Kotlin was checked for syntax errors only, and the external API signatures were checked against the published artifacts.Split out of #221 (now closed), which bundled six Android fixes in
ImageEditorModuleImpl.kt. Each one can be reviewed and merged separately.