facebookresearch / playtorch

PlayTorch is a framework for rapidly creating mobile AI experiences.
https://playtorch.dev/
MIT License
830 stars 101 forks source link

Workaround #198

Open IainBerliner opened 1 year ago

IainBerliner commented 1 year ago

Summary

This is intended to demonstrate the workaround I used in connection to the GitHub issue I created. It's not meant to actually be merged with the main branch.

Changelog

Modified the file PyTorchCoreJSI.mm to repeatedly try installing __torchlive__ if RCTCxxBridge.runtime is null, rather than just giving up.

Modfied the file install-jsi.ts to run all of it's side-effect logic in a function that gets called immediately, and that does a "return;" if the variable "PlayTorchJSIModule" is null, instead of throwing an error. Also added an extra side effect that adds a function to the global object, that can be used to asynchronously await the existence of __torchlive__, before calling other PyTorch code.

Test Plan

The code present in this pull request should prevent the crash that happens when the conditions I mentioned in the GitHub issue are recreated.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
playtorch ❌ Failed (Inspect) Feb 13, 2023 at 2:43AM (UTC)
facebook-github-bot commented 1 year ago

Hi @IainBerliner!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

raedle commented 1 year ago

Thanks @IainBerliner!