Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Repeated rendering to Canvas crashes app on iOS #115

Closed
SomaKishimoto opened this issue Aug 24, 2022 · 10 comments
Closed

Repeated rendering to Canvas crashes app on iOS #115

SomaKishimoto opened this issue Aug 24, 2022 · 10 comments
Assignees
Labels
🐛 bug Something isn't working 🍏 ios Issue related to iOS

Comments

@SomaKishimoto
Copy link

SomaKishimoto commented Aug 24, 2022

Version

0.2.1

Problem Area

react-native-pytorch-core (core package)

Steps to Reproduce

  1. repeat rendering to Canvas

Error message:
Message from debugger: Terminated due to memory issue

just before the crush:
W0821 11:40:23.873222 1881387008 JSIExecutor.cpp:381] Memory warning (pressure level: 1) received by JS VM, unrecognized pressure level

The crush doesn't occur when this commit is ignored.
v0.2.0 doesn't crush app.

What kind of measures should I take?

Expected Results

No response

Code example, screenshot, or link to repository

No response

@raedle
Copy link
Contributor

raedle commented Aug 24, 2022

@SomaKishimoto, thanks for reporting this issue. Can you share the canvas drawing source code?

If the canvas context is used in a rendering loop, then my hunch is that it is missing the ctx.clear() call at the beginning of loop

@raedle raedle self-assigned this Aug 24, 2022
@raedle raedle added 🐛 bug Something isn't working 🍏 ios Issue related to iOS labels Aug 24, 2022
@SomaKishimoto
Copy link
Author

SomaKishimoto commented Aug 24, 2022

@raedle , thanks for your prompt reply.
ctx.clear() is not used as you mentioned because the status is deprecated.
Is this status going to change? , and is there any example instructed to use ctx.clear()?

we refer to this example and do continuous rendering with onFrame instead of onCapture

@raedle
Copy link
Contributor

raedle commented Aug 26, 2022

@SomaKishimoto, there is an issue with the recent change to the iOS canvas. We are investigating on a forward fix. In the meantime, the ctx.clear() will circumvent possible memory issues. Can you give it a try if this unblocks you?

The following PlayTorch Snack shows the usage for ctx.clear(): https://playtorch.dev/snack/@raedle/clear-canvas/

@SomaKishimoto
Copy link
Author

@raedle , thanks! We'll try it and let you know if there is any progress!

@SomaKishimoto
Copy link
Author

Works fine, @raedle! Thanks a lot.

@raedle
Copy link
Contributor

raedle commented Sep 6, 2022

Thanks for reporting back. Closing task!

@raedle raedle closed this as completed Sep 6, 2022
@SomaKishimoto
Copy link
Author

@raedle , Unfortunately, repeated rendering crashes app on iPad Air Gen3 (OS15.5) after running for 4 hours.
The error code is below
Error: W0907 14:44:28.448568 1850142720 JSIExecutor.cpp:381] Memory warning (pressure level: 1) received by JS VM, unrecognized pressure level

I confirmed that the app was working for at least 9 hours on iPhone.
However, I didn't check if it works more than 9 hours, so I'll check it.

@raedle
Copy link
Contributor

raedle commented Sep 8, 2022

@SomaKishimoto, thanks for reporting the memory warning. Can you provide more info on the following three questions?

  • Is the Hermes or JSC enabled as JavaScript Runtime? You can check with the following code
const isHermes = () => !!global.HermesInternal;

https://reactnative.dev/docs/hermes#confirming-hermes-is-in-use

  • Is the app running in debug or release mode?
  • Do you have a crash log that you can share?

@SomaKishimoto
Copy link
Author

SomaKishimoto commented Sep 9, 2022

@raedle , thanks for your prompt reply.
the answers to your questions are as follows.

  • the Hermes is enabled
  • release mode
  • No further information than the log I shared before

It's me that brought this question up, but this problem may be caused by something else.
I'll report back if there seems to be a problem with Playtorch.

@raedle
Copy link
Contributor

raedle commented Sep 9, 2022

Thanks @SomaKishimoto, and please let us know if the issue is with PlayTorch!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Something isn't working 🍏 ios Issue related to iOS
Projects
None yet
Development

No branches or pull requests

2 participants