juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.13k stars 518 forks source link

[UnityAppController applicationDidReceiveMemoryWarning:]: unrecognized selector sent to instance... #842

Closed JosephCarrington closed 9 months ago

JosephCarrington commented 1 year ago

Describe the bug If the app receives a memory warning while running a Unity view, it crashes.

To Reproduce Steps to reproduce the behavior:

  1. Follow setup instructions for AR implementation for iOS.
  2. Do something that is memory intensive (Like loading a lot of giant images, or just opening the profiler and waiting a few seconds)

Expected behavior applicationDidReceiveMemoryWarning should have a handler of some kind that actually exists.

Screenshots Screenshot 2023-07-11 at 3 18 52 PM

Unity (please complete the following information):

Smartphone (please complete the following information):

OgiJr commented 1 year ago

Were you able to find a solution to this error? It causes my app to crash every time it has to do something memory intensive.

alexandrefresnais commented 1 year ago

I am impacted too on my AR app

CodeEagle commented 1 year ago

add - (void) applicationDidReceiveMemoryWarning:(UIApplication *)application {} in file UnityAppController.mm to fix this

timbotimbo commented 9 months ago

I just noticed the following in the Unity changelogs

iOS: Bring back the applicationDidReceiveMemoryWarning: to UnityAppController. (UUM-55367)

This is noted in versions

I can't find when they removed it, but it looks like they fixed it themself.

[Update] I also found

iOS: Fixed low memory usage event not triggered when using Unity as a library. (UUM-20838)

Fixed in 2021.3.28f1, 2022.3.2f1, 2023.1.0f1, 2023.2.0a17

So updating Unity seems your best bet.

Ahmadre commented 9 months ago

I just noticed the following in the Unity changelogs

iOS: Bring back the applicationDidReceiveMemoryWarning: to UnityAppController. (UUM-55367)

This is noted in versions

I can't find when they removed it, but it looks like they fixed it themself.

Good to know that they brought it to both 2021 + 2022.

timbotimbo commented 9 months ago

For reference, this is the function that Unity adds in 2021.3.33, which matches what @CodeEagle mentioned earlier.

- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
{
    // We handle it by subscribing for notification, this one is only a placeholder for stuff like forwarding in UaaL setups
}