Out of (native?) memory crashes on Android React Native, low reported memory usage - reactjs

I'm failing to find concrete information on troubleshooting Out of memory exceptions for RN apps running on Android. I've been getting some OOM errors reported to my Bugsnag dashboard, all of which seem fishy.
The crashes are occurring on the login screen, before any heavy logic / rendering / etc. occurs.
The reported memory usage is low (one crash occurred with 3MB used by the app). This may not include anything used in the NDK though after emailing Bugsnag.
Available memory is far beyond used memory (though not including what is used by the NDK)
This is not isolated to older devices - one crash occured on a Galaxy S9 with the app using 13MB (plus NDK), and 255MB still available.
I of course enabled largeHeap for the time being while I investigate, but I'm still seeing crashes with this low reported memory usage. The only direction I have is checking if RN is eating up native memory, which isn't reported as 'used memory' in my console.
While profiling my app (using a debug variant APK, not against the development server), I do see the native memory usage seems high - 81mb with the app just sitting for a while after logging in. It hovers around 30-40mb prior to logging in.
I've ensured my code isn't making any API calls or loading resources during the crash workflow. The login is fairly simple, consisting of a gradient, some text and views, and react-native-app-auth being loaded to handle a login. I do not see a spike when performing the authentication in that library.
Are there any tools or methods to check why RN is eating so much native space? Or is this just normal? I'm currently on RN 0.57.5, React 16.6.3. I cannot test on iOs devices to check if this is an Android-specific problem.

did you try this ?
Add this to your "android/app/src/main/AndroidManifest.xml"
<application android:largeHeap="true"
ref: https://github.com/facebook/react-native/issues/6799

Related

Silverlight Out Of Browser Laucher has Stopped Working

We are running Silverlight 4 version Web Application same in Silverlight Out Of Browser App but when in Out Of Browser crashes
continuously after some time usage getting message as "Silverlight Out Of Browser Laucher has Stopped Working " and crashes. We have checked Memory usage and it having 530 MB and CPU Usage is 40%.
Is this causing due to any Silverlight plugin issue ? . where as in IE same application works better than OOB app and it crashes rarely but OOB app it crashes continuously . Earlier we have memory leak issue and fixed by implementing proper garbage collection techniques in Dispose method. so its not due memory leak and somethign causes in OOB app that crashes.
Can you any one suggest some possible solutions to avoid following crashing issue or can trace where might causing this issue ? As it is Out of Browser app we cant see page errors . Please suggest some tracing techniques.
Thanks
Krishna
Following IE crashing logs got

React native for android run very slow when not enable "Debug JS"

I am developing an app using react native, I use some code base for ios and android, the ios version run smoothly.
But the android version run very slowly. the weird thing is:
When I shake the phone, and click "Debug JS" to enable debug in chrome feature, it run faster, anyone have a clue about the reason?
Sometimes, one or more than one active console.log() lines cause this issue.
console.log lines should be searched and deleted if they exist.
Also in production, babel-plugin-transform-remove-console can be used to clear all console.* methods automatically.
The reason for different execution speeds of javascript code when running in debug mode and without is that when you are in debug mode, in order to enable the debugging experience React Native executes the code in the Chrome browser on your computer, and the results of the execution are bridged onto the device.
Outside of the debug mode, the code is executed in the JavaScriptCore engine on the device itself.
That said, I cannot explain why the execution is so slow on the device. Are you perhaps running on an low-powered device, or an emulator with limited allocated memory?
React Native app does run slower on Android. But the performance is not real during your development. You can build a release version to check the real performance, release version is much faster than dev version.
There are also some bad codes which can make your app slow. Like console.log(), it does slow the app during development. Avoid unnecessary re-render the view, don't use arrow function and .bind in render, etc.
I have the same issue on IOS device (ipad4, ios10). I don't use redux-logger and removed all console.log, still don't know what makes the app so slow. It takes 2s to swich between tabs.
"react-native": "0.41.2",
"react": "15.4.2",
"native-base": "^2.0.10",
I know it is an old topic but suffered the same problem. I applied the above solutions but the problem still presisted. Later I found out that problem caused by a emulated USB storage device rather than mounted as a USB disk. Because when you upload signed Apk file and install the appllication from this file it causes problems and gives write error e.g. hiddenly but don't gives error messages much. I hope changing from emulated storage device to mounted as a trivial disk helps who suffer the same problem like me.

Why do Selenium tests that pass locally fail on Browserstack specifying exact same browser?

I got a test that opens a webpage and does scraping.
It works. There's no question on that:
- Works on Phantomjs/Chrome/Firefox when run on my machine everytime.
However, when run on Browserstack (I want to cover 5 most popular browsers, several OS and even mobile devices, for the moment I specify the exact same browser and platform as on my machine to ensure first the test runs properly on Browserstack), the test SOMETIMES passes and SOMETIMES fails with different errors:
- Stale element
- No such element in cache
- Page fails to load after a submit
- etc
And almost never the same element or submit.
Which is making me wonder whether Browserstack has some inherent instability I'm not aware of. Has anyone seen this happen on Browserstack?
Welcome to BS. You get such errors because the environments on BS do lag a lot. They aren't giving much resources to their VMs so you will have to deal with it. Or put a lot of thread sleeps and special waits for your needs

GWT Modlue Restarts cause Out of Memory Error

I'm developing a GWT application, and I'm having issues with testing in development mode in eclipse.
When I make changes to the client-side code, I refresh the browser page (F5) to reload the module. Every time I do this (whether the code has changed or not), the Development Tab in eclipse shows a new bullet point with "Module xxxx has loaded". As well, according to Task Manager, every time I do this, the javaw.exe host process increases by about 1MB of memory. Eventually (10-20 refreshes later), the page fails to load and the Development Mode tab shows this error:
Out of memory; to increase the amount of memory, use the -Xmx flag at startup (java -Xmx128M ...)
I can fix this by stopping and restarting the server (not the little refresh button in the Developer Mode tab, but the red stop button), but it then the module has to be revalidated, which takes a while. It seems that eclipse doesn't realize I've finished with the old module when I reload a new one. I'm observing the same behavior with a brand-new GWT project, so I don't think it's my code. Is anyone aware of a way to remedy this?
EDIT: See both answers below for possible solutions.
The default settings gwt dev mode use are the minimum , so you hit an out of memory really quickly.
From this you can see that the permgenspace is to low and if you refresh 20 times in a short periode it will go out of memory.
you can start by using following vmargs :
-Xms512m -Xmx512m -XX:MaxPermSize=256M -XX:+UseParallelGC
But as enrybo pointed out if your application grows it requires more memory:
-Xms512m -Xmx1g -XX:MaxPermSize=256M -XX:+UseParallelGC
There isn't really all that much you can do. As you mentioned you can increase the memory but eventually you'll run into the same problem even with more allocated memory.
I suggest you try to run in Super Dev Mode but in that case you'll need to update the SDK you're using to 2.5.1+. With Super Dev Mode your browser does not need a plugin because it will actually be running true Javascript. You even have the ability to debug in your browser but looking at your Java source (using source maps).

What could be causing my WP7 app to crash on only some models?

I've been working on this problem on and off for about a month. I don't expect anybody to be able to give me a definitive answer. I'm just completely out of ideas at this point and could use anything.
The problem is that my app crashes on only some models of phones. I have an HTC surround and it runs fine. It has also been tested on a Samsung Focus and it works there to. It crashes pretty consistently on a HTC mozart. There are other phones it crashes on but I don't know what models they are. I don't have access to an HTC mozart so debugging has been very difficult.
I'm handling the application UnhandledException event and I have try catch around every background thread. The error handling code never runs.
What I know:
Sometimes it freezes and requires a press of the power button. At least once it required the battery taken out. Most of the time it freezes and then crashes.
Most of the time it crashes on the main menu, before everything displays.
It's not 100% consistent. Sometimes it works for a little bit, but never very long.
It's not because it's out of memory. Most of the time it crashes while using less then 8MB.
When all the exception handling didn't work I added debug logging. This slows things way down but at the same time the issue goes away.
These symptoms make it sound like a deadlock to me. Although I have gone over the code and there is no thread ever entering more then 1 lock at a time.
Any ideas on how I should track this down would be appreciated.
Edit: This is a WP7 version of my game. I've just been able to confirm with a volunteer with an HTC mozart that the simplest conversion of the code meant for to run on the web will crash on the phone. That's code has no networking, isolated storage, or sound.
I also should have mentioned that this has passed certification and was in the marketplace for a few days until I took it down because it got bad reviews (because it was unplayable for some people)
If the devices are locking up, then my suspicions would be to look at the areas where you are closest to the driver level/hardware, which (looking at your game) are:
the display
the sound
It could also be just about due to processing/CPU activity - but generally "User level" code shouldn't be able to lock up your phone - that functionality is reserved for kernel software.
The only way of really testing this is to get hold of a device where this "reliably crashes" (e.g. a Mozart) and to go through the process of disabling bits of functionality one by one.
If this is a Silverlight app, then I'd expect Microsoft to want to help - I'd contact them via AppHub and via their local Evangelist team - they'll have the means and the motivation to assist you.
I'm happy to assist on testing on a developer-unlocked HTC Trophy if that helps!
The only thing I can think of that's unique to the Mozart is that it has an 8MP camera and all others have a 5MP camera.
Are you using a CameraCaptureTask and expecting the returned image to be a certain size?
Other than that, what does the app do? what services and device functionality are you using?
Do you have any network access running on a background thread?
I had roughly the same problem when developing my WP7 app. As far as I can tell it isn't as much model bound as it is device bound. In fact I had my app deployed to 15+ Trophy's (my company gave all their employees one of those) and it would repeatedly crash on some of them all having the same firmware. Some of the feedback I got through the reviews seems to indicate that it also happens in the wild.
In my case the crash occurs primarily (only?) when the app is launched. There does seem to be a strong correlation between internet connectivity and crashing in that I can 'recreate' the crash by putting my phone in flight mode, unplugging the network cable from my computer and then deploying the app. In that case too it immediately crashes and no event or break point is ever raised.
My gut feeling tell me it might have something to do with the map control as that does tend to respond funky to poor connectivity when the application is loading (like displaying an error message that the card cant be loaded while simultaneously displaying the map)
Does your app also use the Map Control (in combination with a Pivot control perhaps?)
Some of the devices have issues where you need set things to "content" instead of "embedded resource" in your project.
Although i've more heard about that issue related to app startup time, as on some devices (HD7?) the load of the app was taking enough time that the app was never allowed to start, the OS thought it was taking too long and killed it.

Resources