Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async simultaneously loading two mediapipe packages (Hand Pose + Selfie Segmentation) leads to loading error at load time. #2823

Closed
Harleyzheng opened this issue Nov 26, 2021 · 4 comments
Assignees
Labels
legacy:hands Hand tracking/gestures/etc legacy:selfie segmentation Issues related to selfie segmentation platform:javascript MediaPipe Javascript issues type:feature Enhancement in the New Functionality or Request for a New Solution

Comments

@Harleyzheng
Copy link

Harleyzheng commented Nov 26, 2021

Please make sure that this is a bug and also refer to the troubleshooting, FAQ documentation before raising any issues.

System information (Please provide as much relevant information as possible)

  • Have I written custom code (as opposed to using a stock example script provided in MediaPipe):
    no

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04, Android 11, iOS 14.4):
    macos 12

  • Browser and version (e.g. Google Chrome, Safari) if the issue happens on browser:
    chrome

  • Programming Language and version ( e.g. C++, Python, Java):
    javascript, node

  • MediaPipe version:
    node_modules/@mediapipe/hands
    node_modules/@mediapipe/selfie_segmentation/

  • Solution ( e.g. FaceMesh, Pose, Holistic ):
    Hand Pose + Selfie Segmentation

Describe the current behavior:
Async simultaneously loading two mediapipe packages (Hand Pose + Selfie Segmentation) leads to loading error at load time.
The hands_solution wasm incorrectly inter-loads selfie_segmentation_solution wasm code. We implemented a Mutex to force loading the two packages synchronously to resolve this issue.

Please see below error stack:

Uncaught (in promise) RuntimeError: abort(Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)) at Error
    at jsStackTrace (:3000/mpss/selfie_segmentation_solution_simd_wasm_bin.js:9)
    at stackTrace (:3000/mpss/selfie_segmentation_solution_simd_wasm_bin.js:9)
    at abort (:3000/mpss/selfie_segmentation_solution_simd_wasm_bin.js:9)
    at Object.get (:3000/mpss/selfie_segmentation_solution_simd_wasm_bin.js:9)
    at :3000/mph/hands_solution_simd_wasm_bin.js:9
    at pa.h (:3000/static/js/vendors~main.chunk.js:3980)
    at G (:3000/static/js/vendors~main.chunk.js:2381)
    at sa.next (:3000/static/js/vendors~main.chunk.js:2411)
    at :3000/static/js/vendors~main.chunk.js:2444
    at new Promise (<anonymous>)
    at ta (:3000/static/js/vendors~main.chunk.js:2439)
    at H (:3000/static/js/vendors~main.chunk.js:2449)
    at :3000/static/js/vendors~main.chunk.js:3979
    at async Promise.all (:3000/index 0)
    at abort (:3000/mpss/selfie_segmentation_solution_simd_wasm_bin.js:9)
    at Object.get (:3000/mpss/selfie_segmentation_solution_simd_wasm_bin.js:9)
    at :3000/mph/hands_solution_simd_wasm_bin.js:9
    at pa.h (:3000/static/js/vendors~main.chunk.js:3980)
    at G (:3000/static/js/vendors~main.chunk.js:2381)
    at sa.next (:3000/static/js/vendors~main.chunk.js:2411)
    at :3000/static/js/vendors~main.chunk.js:2444
    at new Promise (<anonymous>)
    at ta (:3000/static/js/vendors~main.chunk.js:2439)
    at H (:3000/static/js/vendors~main.chunk.js:2449)
    at :3000/static/js/vendors~main.chunk.js:3979
    at async Promise.all (:3000/index 0)

Describe the expected behavior:
More than one solution engines should be loaded successfully at the same time.

Standalone code to reproduce the issue:
Provide a reproducible test case that is the bare minimum necessary to replicate the problem. If possible, please share a link to Colab/repo link /any notebook:

From codepen.io, simply run the following:
=======start========
const mpHands = window;

const selfieSegmentation = new SelfieSegmentation({locateFile: (file) => {
return https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/${file};
}});
selfieSegmentation.initialize();

const config = {locateFile: (file: string) => {
return https://cdn.jsdelivr.net/npm/@mediapipe/hands@${mpHands.VERSION}/${file};
}};
const hands = new mpHands.Hands(config);
hands.initialize()

========end=========

selfie_segmentation_solution_simd_wasm_bin.js:9 Uncaught (in promise) RuntimeError: abort(Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)) at Error
    at jsStackTrace (selfie_segmentation_solution_simd_wasm_bin.js:9)
    at stackTrace (selfie_segmentation_solution_simd_wasm_bin.js:9)
    at abort (selfie_segmentation_solution_simd_wasm_bin.js:9)
    at Object.get (selfie_segmentation_solution_simd_wasm_bin.js:9)
    at selfie_segmentation_solution_simd_wasm_bin.js:9
    at pa.h (hands.js:57)
    at G (hands.js:14)
    at sa.next (hands.js:15)
    at hands.js:15
    at new Promise (<anonymous>)
    at abort (selfie_segmentation_solution_simd_wasm_bin.js:9)
    at Object.get (selfie_segmentation_solution_simd_wasm_bin.js:9)
    at selfie_segmentation_solution_simd_wasm_bin.js:9
    at pa.h (hands.js:57)
    at G (hands.js:14)
    at sa.next (hands.js:15)
    at hands.js:15
    at new Promise (<anonymous>)
    at ta (hands.js:15)
    at H (hands.js:16)

@Harleyzheng Harleyzheng added the type:bug Bug in the Source Code of MediaPipe Solution label Nov 26, 2021
@1o1w1
Copy link

1o1w1 commented Nov 27, 2021

+1

@sgowroji sgowroji added platform:javascript MediaPipe Javascript issues legacy:selfie segmentation Issues related to selfie segmentation stat:awaiting googler Waiting for Google Engineer's Response legacy:hands Hand tracking/gestures/etc labels Nov 28, 2021
@sgowroji sgowroji assigned tyrmullen and mhays-google and unassigned sgowroji Nov 28, 2021
@tyrmullen
Copy link

Correct-- currently the initializers don't play nicely together. But you shouldn't need anything complicated-- just adding await before the .initialize() calls (specifically await selfieSegmentation.initialize()) should be sufficient.

However, leaving this bug open, as it would be a nice thing for us to have, although this isn't something I'll be able to tackle myself any time soon, so unassigning myself.

@mhays-google
Copy link
Contributor

Definitely a useful feature, but we do not currently support loading multiple systems into the same page. There is no projection on when this functionality would be available.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy:hands Hand tracking/gestures/etc legacy:selfie segmentation Issues related to selfie segmentation platform:javascript MediaPipe Javascript issues type:feature Enhancement in the New Functionality or Request for a New Solution
Projects
None yet
Development

No branches or pull requests

5 participants