Files
opencv-MIRROR/modules/js/test
熊建祐 1d740084b7 Merge pull request #30433 from JoyBoy900908:fix/js-mat-clone-emscripten
fix(js): restore deep copy behavior of Mat.clone() - #30433

## Description

Fixes #30408.

With Emscripten 4+, the existing `onRuntimeInitialized` callback can be registered after runtime initialization has already completed. As a result, the override of Emscripten's shallow `ClassHandle.clone()` is never applied, causing `cv.Mat.clone()` to perform a shallow copy instead of the expected deep copy.

This PR applies the `mat_clone` override immediately when `cv.Mat` is available, while retaining the initialization callback as a fallback.

## Changes

- Restore deep-copy behavior for `cv.Mat.clone()`.
- Preserve the existing `onRuntimeInitialized` callback.
- Add regression tests for matrix data independence and cloning non-contiguous ROIs.

## Testing

Environment:
- OpenCV 5.x
- Emscripten 6.0.12
- Node.js 22.23.3

Results:
- Confirmed the original shallow-copy behavior before the fix.
- Verified deep-copy behavior after the fix.
- Verified that cloning a non-contiguous ROI produces independent, continuous data.
- `CoreMat.test_mat_creation`: 91/91 assertions passed.
- Full OpenCV.js test suite: 414 passed, 8 failed.

The remaining eight failures involve heap-memory views and unavailable JavaScript bindings. These failures have not yet been verified against an unmodified baseline.
2026-10-22 10:34:34 +03:00
..
2021-11-18 12:13:05 +00:00
2024-12-01 23:17:35 +03:00
2025-11-18 08:51:08 +03:00
2026-02-14 15:37:33 +03:00
2025-06-10 10:16:50 +03:00
2024-12-01 23:17:35 +03:00