This question suggests using console.time, but that isn't available in React Native. Is there a built in way to measure how long a function call takes, without using any third-party packages?
Using react-native v0.63 (not sure about lower versions), you can use the performance api, which is described in the question you linked in the OP.
var t0 = performance.now()
doSomething() // <---- measured code goes between t0 and t1
var t1 = performance.now()
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
I ran into the same error but managed to fix it easily, just enable debugging on your app to use chrome or react native debugger. From the console of these debuggers, the console.time() and console.timeEnd() is supported and works perfectly
you can use console.time but throw third party packages react-native-console-time-polyfill
otherwise with performance monitor from developer menu Show Perf Monitor
Related
I am developing an Android app that gets data from Movesense using the GATT profile from the sample app GATT Sensor Data App here.
I followed the tutorial available here. Building the app and getting the DFU worked fine. I can get IMU, HR and temperature data with no issues.
Now I'd like add a tap detection feature to my app. I understand that I have to subscribe to 'System/States', but first I need to be able to receive the system state data.
I understand that I need a modified DFU for that, but I don't understand what changes I should make in which files of the gatt_sensordata_app before rebuilding and generating the new DFU.
What changes should I make in order to broadcast /System/State data?
(I usually just deal with Android so apologies for the very basic question.)
I tried adding #include "system_states/resources.h" to GATTSensorDataClient.cpp but I don't know how to continue.
The normal data straming in the gatt_sensordata_app uses the sbem-encoding code that the build process generates when building the firmware. However /System/States is not among the paths that the code can serialize. Therefore the only possibility is to implement the States-support to the firmware.
Easiest way is to do as follows:
In your python app call data subscription with "/System/States/3" (3 == DOUBLE_TAP)
Add a special case to the switch in onNotify which matches the localResourceId to the WB_RES::LOCAL::SYSTEM_STATES_STATEID::LID
In that handler, return the data the way you want. Easiest is to copy paste the "default" handler but replace the code between getSbemLength() & writeToSbemBuffer(...) calls with your own serialization code
Full disclosure: I work for the Movesense team
I am trying to figure out what parts of my React Native app are causing Detox to wait unnecessarily long as instructed in the documentation. However, when I run:
detox test --debug-synchronization 20
I get no additional output, only the regular Jest output. I know for a fact that there are network requests slower than that, setTimeout's of 400 ms and animations which are slowing Detox down, but it doesn't output them.
What could be causing the output not to work?
This feature had a bug before and they just fixed it in this release: 18.18.0
You may consider this apprach as well
await device.disableSynchronization();
put this line before interacting with the animated element
and then you can enable the synchorization again
await device.enableSynchronization();
AsyncStorage.getItem takes long time to get data, sometimes no response at all. I do understand that getItem is async function. But the amount of waiting time is not acceptable and not reasonable.
Anyone facing such issue? any workaround?
the react-native version is 0.55.4
If anyone is is still having this issue with RN >= 0.60 & Async-Storage >= 1.6.1, I solved the issue by setting a dedicated thread executor in android as outlined here: https://github.com/react-native-community/async-storage/blob/LEGACY/docs/advanced/DedicatedExecutor.md
Haxe porgramming beginner here and I can't seem to find a solution for my problem.
I'm simply running another program on the computer via sys.io.Process.
import sys.io.Process;
import neko.Lib;
class Main
{
static function main()
{
var cProcess = new Process(pClient + sArgs);
}
}
I only want my Haxe program to be running as long as the "cProcess" exists.
So I need some kind of Eventhandler that calls a function when the cProcess is being closed.
Does anyone have an idea how to solve this problem?
Any suggestions welcome!
Thanks!
If all you want to do is wait for the process to complete it's execution
just call exitCode(), it will block until launched process exits.
var cProcess = new Process(pClient + sArgs);
cProcess.exitCode();
trace("Done!");
Mihail's solution is simple and should work.
If you need more on that, you can try asys, which is the asynchronous version of the sys package in Haxe standard library.
var process = new asys.io.Process('your command');
process.exitCode().handle(function(code) trace('process exited with code: $code'));
It also depends on the platform you are running on. If you are running on platforms with async io like nodejs, things should be simple. Otherwise you have to consider threads.
I'm working on an existing app that I did not develop, and it plays its audio using FMOD.
From the looks of things, previous versions of the app were written to use AVAudioPlayer instead, and there are build options to use either.
The most recent versions use FMOD though, because a lot of the functionality is only included when built using the FMOD version.
The problem comes when I use one of the existing apps first, then try to run this new one that I'm developing.
If I run one app, then leave it in the background and run the second app, the sound in the second app doesn't play at all. I can go back to the first app and play sound without problems. If I kill both apps, and start the other one first, then it works perfectly.
If I build the app using the AVAudioPlayer option, then I don't get this problem, but also all of the functionality that was written for the FMOD version is not there. I can therefore prove that it is something to do with FMOD, but can't figure out what.
EDIT:
Have done a little more digging, and I'm getting two FMOD errors:
Firstly, when I run:
result = fmodSystem->init(4, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL);
I get error 51 - "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere."
Secondly, when I run:
result = fmodSystem->createSound((const char *)[audioData bytes], FMOD_SOFTWARE | FMOD_OPENMEMORY, &exinfo, &fmodSound);
I get error 79 - "This command failed because System::init or System::setDriver was not called."
The second seems to be because the init failed.
This was answered via Twitter, therefore I'll put the answer here myself, however, if Stuart would like to answer it himself here, then I'll vote that as the answer.
The answer is to disable: FMOD_INIT_ENABLE_PROFILE, because that can only run in one app at a time:
Therefore, this:
result = fmodSystem->init(4, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL);
Should become this:
result = fmodSystem->init(4, FMOD_INIT_NORMAL, NULL);