Conversation
This commit introduces a new API to retrieve memory usage statistics from the underlying JavaScript/WASM engine. Key changes: - Created `MemoryUsage` data class to hold heap statistics. - Updated `Jp2kDecoderAsync` to inject a `getMemoryUsage` JS function into the sandbox, which queries `wasmInstance.exports.memory` and `performance.memory`. - Added `getMemoryUsage()` method to `Jp2kDecoderAsync` and `Jp2kDecoder` to expose this data to the application layer. - Updated `Jp2kDecoderTest` to verify the new API and fixed incorrect constructor usage in the test.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Updates the sample app `MainActivity` to utilize the newly added `getMemoryUsage()` API. Key changes: - Calls `decoder.getMemoryUsage()` after decoding the image. - Displays the WASM and JS heap statistics in the UI. - Imports `MemoryUsage` and necessary Compose UI components.
This commit updates the KDoc for `MemoryUsage` to explicitly state that JS heap statistics (`jsHeapSizeLimit`, `totalJSHeapSize`, `usedJSHeapSize`) may be null if the underlying `performance.memory` or `console.memory` APIs are restricted or unavailable in the Android `JavaScriptEngine` environment. Also added a fallback to check `console.memory` in `Jp2kDecoderAsync` to increase the chance of retrieving memory stats on supporting environments.
This commit updates `MemoryUsage` documentation to cite MDN as the source for the non-standard `performance.memory` API, fulfilling the requirement to document the origin of these values and explain their potential unavailability in the Android `JavaScriptEngine` sandbox.
This commit modifies the `getMemoryUsage` API to remove JS heap statistics as they are generally unavailable in the Android `JavaScriptEngine` sandbox. It focuses solely on `wasmHeapSizeBytes`. Also updates the `MainActivity` sample to retrieve and display the WASM heap size before and after decoding an image, allowing users to visualize memory consumption changes. Changes: - Removed JS heap fields from `MemoryUsage`. - Simplified `getMemoryUsage` JS injection in `Jp2kDecoderAsync`. - Updated `MainActivity` to show "Before -> After" heap size.
Added
getMemoryUsage()API toJp2kDecoderandJp2kDecoderAsyncto allow applications to monitor WASM and JS heap usage. This involved injecting a helper function into the JavaScript sandbox and parsing the result. Also fixed a constructor mismatch inJp2kDecoderTest.PR created automatically by Jules for task 8363786151944416957 started by @keiji