What's the relationship between Dalvik and Zygote process? - android

I just want to know :
Who created the dalvik_Vm ?
Is the zygote process running in the vm or contrary?

Dalvik VM was authored by Dan Bornstein
Every android application runs in a separate process, has its own Dalvik VM.
Zygote is a daemon with the only mission to launch applications. This means that Zygote is the parent of all App process. When app_process launches Zygote, it creates the first Dalvik VM and calls Zygote’s main () method. Once Zygote starts, it preloads all necessary Java classes and resources, starts System Server and opens a socket /dev/socket/zygote to listen for requests for starting applications.

Add some example to explain that Zygote is the parent of all App process.
zygote PID : 481, my application processes PPID : 481, you can use ps command to check.
UID PID PPID C STIME TTY TIME CMD
root 481 1 0 09:17:54 ? 00:00:03 zygote
u0_a132 28993 481 78 09:07:53 ? 00:23:46 com.languouang.helloworld
u0_a132 29013 481 0 09:07:53 ? 00:00:01 com.languouang.helloworld:countservice
u0_a132 29296 481 1 09:09:04 ? 00:00:09 com.languouang.helloworld:mall
u0_a132 30427 481 1 09:16:42 ? 00:00:15 com.languouang.helloworld:faq

Zygote actually the child of init process which occur as boot process start.
It is responsible of loading Dalvik virtyal machine by which our Dalvik Bytecode get executed. Also, it preload all the necessary resource all shared java classes and resources into memory.

Zygote is one of the first init processes created after the device boots. It initializes the Dalvik virtual machine and tries to create multiple instances to support each Android process. As discussed in earlier sections, the Dalvik virtual machine is the virtual machine that executes Android applications written in Java.
Zygote facilitates using a shared code across the VM, hence, helping to save the memory and reduce the burden on the system. After this, applications can run by requesting new Dalvik virtual machines. Zygote registers a server socket for zygote connections and preloads certain classes and resources. This zygote loading process has been more clearly explained at https://elinux.org/Android_Zygote_Startup ...

Related

Should both healthd and android.hardware.health#2.0-service.imx be running?

On my Android system, there are two separate healthd processes:
$ adb shell "ps -ef | grep health"
root 3535 1 3 14:33:18 ? 00:00:00 healthd
system 3548 1 5 14:33:18 ? 00:00:00 android.hardware.health#2.0-service.imx
They both use the same code from system/core/healthd and hardware/interfaces/health/2.0/default, but only android.hardware.health#2.0-service.imx uses code from vendor/nxp-opensource/imx/health.
Is there any reason for both to run?
Should NXP (or downstream vendor) have stopped the default Android healthd from building/running?
Update:
The .rc files for the two services differ:
smarc_mx8mq:/etc/init # cat healthd.rc
service healthd /system/bin/healthd
class hal
critical
group root system wakelock
smarc_mx8mq:/etc/init # cat /vendor/etc/init/android.hardware.health#2.0-service.imx.rc
service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health#2.0-service.imx
class hal
user system
group system
capabilities WAKE_ALARM
file /dev/kmsg w
Removing /etc/init/healthd.rc from the built system causes the vanilla healthd not to start. I have not yet noticed any ill effects.
healthd is version 1.0 hal, it can be removed. ref: Removing healthd

Android Bundle package crash on startup

My Delphi project have both android 32 and 64 destination. I can deploy them on my test devices and they both works fine.
Now google forces me to upload a single app bundle file (.aab), so i flagged the "Generate Android App Bundle file (arm + arm64)" option, set up my provisioning keystore, loaded the alias and then generated that .aab file
I uploaded that as a beta release for my app from the android developer portal and after a few hours it became available to download for my test devices. But.. it shows the start up logo.. and nothing else.
I don't really know how to debug this since both the apks are working fine (32 and 64 bit), so i tried to launch adb logcat *:W, but i still cannot get useful info. I got those lines in endless loop:
10-30 09:59:21.656 13723 13723 E systems.<my app name>: Not starting debugger since process cannot load the jdwp agent.
10-30 09:59:21.688 13723 13723 W systems.<my app name>: JIT profile information will not be recorded: profile file does not exits.
10-30 09:59:21.688 13723 13723 W systems.<my app name>: JIT profile information will not be recorded: profile file does not exits.
10-30 09:59:21.703 922 1100 E ANDR-IOP: IIop:: Iop HAL Service is not available.
10-30 09:59:21.707 13723 13743 E Perf : Fail to get file list oat
10-30 09:59:21.707 13723 13743 E Perf : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
10-30 09:59:21.743 13723 13723 W linker : Warning: "/data/app/<my app name>-43xRWdYLtXcvUAbEkuUk6g==/split_config.arm64_v8a.apk!/lib/arm64-v8a/lib<my app name>.so" unused DT entry: DT_RPATH (type 0xf arg 0x2cf24) (ignoring)
Just for info: getFolderSize() is not a function i use in my code (its not even declared).
Also, i think this is pretty important: my app deploys some .so files (different files for 32 and 64 bit) and some other files, like images and fonts.
Why i think this is important? Just a suspect born reading this similar issue (but with xamarin): https://github.com/xamarin/Xamarin.Forms/issues/11450
I also tried to deploy the .aab manually on my devices but the only thing i found is how to generate the .apks file from the .aab, and i still cannot deploy it on my devices.
I'm using Delphi 10.4.1 and i also tried to recreate the .dproj file setting up everything again.
How i can debug this? Or how i can get more info about the cause?
Edit: Solved it! I had a few problems that, mixed together, caused this; i'll try to list them in case someone will have a similar issue and will end here!
my androidmanifest.template.xml file was generated by an older version of delphi and was missing some important parts
you need to include all the needed .so files in both 32 and 64bit build to actually have them in the bundle
using TPath.GetLibraryPath() when loading .so files can produce different results if you are using it inside a .aab bundle package
i was trying to load one of those .so file from the initialization section using the function TPath.GetLibraryPath() to get the root path, that was causing a unhandled exception that make my app crash into the splash screen
I solved simply removing TPath.GetLibraryPath() from the path i was using to load my .so and now it works

About "init: untracked pid xxxx exited" in Genymotion

Sometimes I see the following logcat output such as that below:
<3>[ 283.152845] init: untracked pid 4217 exited
<3>[ 283.162185] init: untracked pid 4078 exited
<3>[ 283.173691] init: untracked pid 1504 exited
<3>[ 283.177018] init: untracked pid 1468 exited
What is the meaning of the log of init: untracked pid xxxx exited?
use logcat and read the huge log carefully. You might find the program that crashes all the time.
There may be many different reasons, one of them is that android init trying to
initialize services specified by init.rc failed.
You can try to bisect the services started from init.rc first, and once you find
the errornous service, then try to fix the specific service start up errors, which
may be the kernel driver error, or android hal driver error, library fault, or
sometimes android framework error.
Technically, this message (modern version of which is "Untracked pid XXX exited with status YY") means that Android init sees a child process exit (that is, receives SIGCHLD signal and then gets its pid with waitpid()), but it can't associate that process with any of configured services (see this question on Android init service configuration).
This in turn opens up a question of what can daemonize itself in Android environment and how to find it. But I don't think that I can answer that, the only suggestion that I have is getting root access and checking processes.

Analyzing coredump from java app on android

I have a core dump from dalvik process (it was com.android.browser).
I definitely know, that process was terminated somewhere in JNI module.
Also, I have all debug symbols for that device. But I can't invoke gdb for this coredump.
I'm trying like this:
arm-eabi-gdb ../symbols/system/bin/dalvikvm android.browser_5879_1354575922.core
but gdb says:
warning: core file may not match specified executable file.
.....
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Core was generated by `com.android.browser'
Program terminated with signal 11, Segmentation fault.
so (gdb) info sharedlibrary displays nothing:
No shared libraries loaded at this time.
How to properly load coredump for dalvikvm process?
Ok, answer was to provide app_process as image name:
arm-eabi-gdb symbols/system/bin/app_process android.browser_5879_1354575922.core

How do I debug Android native lib in eclipse with ARM DS-5 without going crazy?

I summon the Android NDK debugging Ninjas here!
I've tried so many tutorials about debugging Android native code, so I can't remember them all.
Now I'm trying to get ARM DS-5 work. I've made it work with the Android NDK samples, where the main Activity loads the library. Laggy, but works.
But my project is a little bit complicated. My Main Activity has a button, when I tap it, SubActivity is launched, and it loads native lib. When I just try to use the DS-5 debugger, when Main Activity is loaded, I suppose debugger tries to connect to lib, but fails, saying:
Execution stopped at: 0xAFD0C52C
Connected to unknown platform
0xAFD0C52C POP {r4,r7}
file "D:\workspace\Project\bin\app_process"
WARNING(IMG53): app_process has no line debug information
add-symbol-file "D:\workspace\Project\bin\libc.so"
Loading library symbols: libc.so
WARNING(IMG53): libc.so has no line debug information
Execution stopped at: 0xAFD0C748
In thread 2 (OS thread id 7606)
In __futex_syscall3 (no debug info)
add-symbol-file "D:\workspace\Project\obj\local\armeabi\libName.so"
Execution stopped at: 0xAFD0C748
In thread 3 (OS thread id 7607)
Execution stopped at: 0xAFD0BFFC
In thread 4 (OS thread id 7608)
In __rt_sigtimedwait (no debug info)
Execution stopped at: 0xAFD0B854
In thread 5 (OS thread id 7609)
In select (no debug info)
Execution stopped at: 0xAFD0C748
In thread 6 (OS thread id 7610)
In __futex_syscall3 (no debug info)
Execution stopped at: 0xAFD0B70C
In thread 7 (OS thread id 7611)
In __ioctl (no debug info)
Execution stopped at: 0xAFD0B70C
In thread 8 (OS thread id 7612)
Execution stopped at: 0xAFD0C52C
In thread 1 (OS thread id 7605)
In epoll_wait (no debug info)
0xAFD0C52C POP {r4,r7}
WARNING(CMD454): The shared library D:\workspace\Project\obj\local\armeabi\libName.so is currently not loaded by the application so the request has been pended
cd "D:\workspace"
Working directory "D:\workspace"
directory "D:\workspace\Project"
Source directories searched: D:\workspace\Project;$cdir;$cwd;$idir
break -d -p "D:\workspace\Project\jni\Name.cpp":525
WARNING(CMD452-COR167):
! Breakpoint 1 has been pended
! No compilation unit matching "D:/workspace/Project/jni/Name.cpp" was found
condition 1
break-script 1 ""
ignore 1 0
break-stop-on-threads 1
unsilence 1
Breakpoint 1 unsilenced
I think that it tries to connect to native lib when Main Activity starts. But library is loaded later!
What I tried:
Setting Java breakpoint in SubActivity, after native lib was loaded,
then attaching DS-5 debugger. But I get various errors from Eclipse
saying about timeouts, whatever.
In the debug config settings I can't
select the activity, which should trigger debugging of native code,
there's combobox, but it's disabled:
The question itself: if my lib is not loaded by main Activity, how do I make DS-5 wait for lib to load?
Do you really need to have exact behaviour between debug and release version ?
If not, load the library in the main activity, too in debug version.

Categories

Resources