Issues with mflinger/mclient - MLockBuffer failed

117 views
Skip to first unread message

Luka Poli

unread,
Mar 10, 2021, 10:50:49 AM3/10/21
to Maru OS dev
Hello everybody,

currently I'm trying to port Maru OS for Xiaomi Mi 8 (Android 9 base). I successfully compiled a custom kernel with features enabled for LXC. My second step was to check whether mflinger and mclient are working in a chroot environment. So I setup the Debian container and started lightdm/X11 without any problems. Additionally the mflinger executable is running with root privileges on my Android system.

Whenever I try to execute the mclient in the Debian environment I get the following output:

<6>intial screen config: 1920x1080 508mmx286mm
<6>syncing true display resolution...
<6>found supported mode: 1920x1080
<6>found supported mode: 1280x720
<6>setting screen size to 1280x720 338mmx190mm
<6>waiting for ScreenChangeNotify events...
<6>[t=5653401]: screen size changed to 1920x1080 508mmx286mm
<6>waiting for ScreenChangeNotify events...
<6>[t=5653401]: screen size changed to 1280x720 508mmx286mm
<3>error receiving buffer fd: Resource temporarily unavailable
<3>MLockBuffer failed!
<3>failed to render cursor sprite
<3>error creating shm segment: Function not implemented
<2>CRITICAL: failed to create xshm

I also executed mflinger via strace to get more verbose output (this is the excerpt of what I think is causing the issue):

write(2, "<3>error receiving buffer fd: Re"..., 63<3>error receiving buffer fd: Resource temporarily unavailable) = 63
write(2, "<3>MLockBuffer failed!\n", 23<3>MLockBuffer failed!

This is the output of logcat:

03-10 12:35:01.540  5766  5766 W mflinger: getDisplayInfo() for eDisplayIdHdmi failed!
03-10 12:35:01.540  5766  5766 W mflinger: Use default display size 1280 x 720 for at last.
03-10 12:35:01.543   581  1253 E BufferQueueProducer: [] disconnect: unknown API -642700512
03-10 12:35:01.543  5766  5766 E mflinger: failed to lock buffer
03-10 12:35:01.544  5766  5766 E mflinger: Client closed connection.

I also tried to connect the phone via screen share to my TV and also to hook up a DisplayLink docking station. The behaviour didn't change.

I would appreciate your help very much. Hopefully we will get this awesome OS onto Mi8 and further devices! :)

Best Regards
Luka

utzcoz

unread,
Mar 10, 2021, 11:01:56 AM3/10/21
to Luka Poli, Maru OS dev
> 03-10 12:35:01.543   581  1253 E BufferQueueProducer: [] disconnect: unknown API -642700512

From this error log, the `mflinger` calls the wrong or non-exist API. Could you check whether the patch
under `frameworks/natives` to add API is merged to local repository? The commit is here:

--
You received this message because you are subscribed to the Google Groups "Maru OS dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maru-os-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maru-os-dev/494b5842-11e3-4456-9064-04bc18c242b0n%40googlegroups.com.

Luka Poli

unread,
Mar 10, 2021, 12:49:41 PM3/10/21
to Maru OS dev

Thanks for your quick response!
You are totally right, I forgot to merge this particular patch - sorry...
I will do that in the next few weeks (unfortunately not a lot spare time right now) and get back here whether it worked.

Luka Poli

unread,
Mar 12, 2021, 6:18:56 PM3/12/21
to Maru OS dev
I did a successful merge of the missing patch and compiled a new ROM.
Now I'm getting a different error when running mflinger and mclient, see below:

mclient:

<6>intial screen config: 1920x1080 508mmx286mm
<6>syncing true display resolution...
<6>found supported mode: 1920x1080
<6>found supported mode: 1280x720
<6>setting screen size to 1280x720 338mmx190mm
<6>waiting for ScreenChangeNotify events...
<6>[t=2005881]: screen size changed to 1280x720 508mmx286mm

<3>error creating shm segment: Function not implemented
<2>CRITICAL: failed to create xshm

mflinger (logcat):

03-13 00:13:47.053  2354  2354 D QtiCarrierConfigHelper: WARNING, no carrier configs on phone Id: 0
03-13 00:13:49.962 10234 10234 I mflinger: At your service!
03-13 00:13:51.367  2354  2354 D QtiCarrierConfigHelper: WARNING, no carrier configs on phone Id: 0
03-13 00:13:55.519 10234 10234 W mflinger: getDisplayInfo() for eDisplayIdHdmi failed!
03-13 00:13:55.520 10234 10234 W mflinger: Use default display size 1280 x 720 for at last.
03-13 00:13:55.608   540   540 I hwservicemanager: getTransport: Cannot find entry android.hardware.graphics.mapper@3.0::IMapper/default in either framework or device manifest.
03-13 00:13:55.609 10234 10234 W Gralloc3: mapper 3.x is not supported
03-13 00:13:55.619 10234 10234 E mflinger: Client closed connection.
03-13 00:13:56.047  2354  2354 D QtiCarrierConfigHelper: WARNING, no carrier configs on phone Id: 0
03-13 00:13:58.742  2267  9782 D DhcpClient: Broadcasting DHCPDISCOVER
03-13 00:13:58.774 10234 10234 W mflinger: getDisplayInfo() for eDisplayIdHdmi failed!
03-13 00:13:58.774 10234 10234 W mflinger: Use default display size 1280 x 720 for at last.
03-13 00:13:58.783 10234 10234 E mflinger: Client closed connection.
03-13 00:14:00.010  2090  2090 D KeyguardClockSwitch: Updating clock: 12:14
03-13 00:14:01.229  5396  5411 W System  : A resource failed to call close.


It's a little bit closer now, but still I'm not sure what is missing now. I would appreciate your help.

utzcoz

unread,
Mar 12, 2021, 11:58:28 PM3/12/21
to Luka Poli, Maru OS dev
The answer saied the chroot doesn't have /dev/ashmem. Could you start Linux manually with lxc-start --name default, and check
whether /dev/ashmem exists on Linux? The default username and password for Linux are both maru.

I recommend you use the prebuilt Linux rootfs from GitHub release page, and you can use the self-built version after it works for you.
The current Linux rootfs upgraded to Debian 10, and it upgrades systemd that uses kernel features only exists on newer kernels.
So if your Mi 8 uses the old kernel, maybe it can affect you.

Luka Poli

unread,
Mar 13, 2021, 11:37:06 AM3/13/21
to Maru OS dev

Thanks for pointing me in the right direction.
It was indeed an issue with the ashmem, the feature somehow didn't work in my first kernel properly (CONFIG_SYSVIPC).
Now I have chosen a different kernel, enabled all features and the error message is gone! By the way, I'm using now the Debian container provided by Maru.

But still I can't get anything as output (screen share or Displaylink). I will again post the output of mflinger/mclient here.

mclient (no error anymore, process is running):

<6>intial screen config: 1920x1080 508mmx286mm
<6>syncing true display resolution...
<6>found supported mode: 1920x1080
<6>found supported mode: 1280x720
<6>setting screen size to 1280x720 338mmx190mm
<6>waiting for ScreenChangeNotify events...
<6>[t=1030041]: screen size changed to 1920x1080 508mmx286mm

<6>waiting for ScreenChangeNotify events...
<6>[t=1030041]: screen size changed to 1280x720 508mmx286mm

mflinger (logcat):

03-13 17:31:00.013  2079  2079 D KeyguardClockSwitch: Updating clock: 5:31
03-13 17:31:02.921 13000 13000 I mflinger: At your service!
03-13 17:31:06.449  2300  2300 D QtiCarrierConfigHelper: WARNING, no carrier configs on phone Id: 0
03-13 17:31:09.231  1490  2855 D WificondControl: Scan result ready event
03-13 17:31:18.015 13000 13000 W mflinger: getDisplayInfo() for eDisplayIdHdmi failed!
03-13 17:31:18.015 13000 13000 W mflinger: Use default display size 1280 x 720 for at last.
03-13 17:31:18.034   542   542 I hwservicemanager: getTransport: Cannot find entry android.hardware.graphics.mapper@3.0::IMapper/default in either framework or device manifest.
03-13 17:31:18.035 13000 13000 W Gralloc3: mapper 3.x is not supported
03-13 17:31:27.145  2300  2300 D QtiCarrierConfigHelper: WARNING, no carrier configs on phone Id: 0

Somehow I'm still missing something. Still happy about your help!

Luka Poli

unread,
Mar 14, 2021, 3:07:31 PM3/14/21
to Maru OS dev
Quick update from my side, I compiled the full Maru Image again and flashed the OTA for dipper on my device.
It didn't went past the manufacturer logo, so I set selinux to permissive and afterwards the Maru logo appeared.
But now I'm stuck in bootloop and can't get any logs. I would appreciate your help a lot!

Luka Poli

unread,
Mar 15, 2021, 12:14:28 PM3/15/21
to Maru OS dev
I would need some help...
Maru is booting fine now with selinux enforcing, but I can see a lot of "avc: denied". So the services are not started properly.
If I set it back to permissive, I get the bootloop. Any idea on how to fix these issues?

utzcoz

unread,
Mar 15, 2021, 12:31:10 PM3/15/21
to Luka Poli, Maru OS dev
Update your MaruOS maru-0.7 code base,  I have fixed some selinux problem. If you also have selinux problem after that, I will send the method I use to fix the selinux.

If your device needs prioriety vendor , maybe you should extract and bound it to vendor.img. The LineageOS can tell whether one device needs prioriety vendor and how to extract it. I have encountered the loop booting problem when porting Pixel, and it is caused by missed prioriety vendor.

Luka Poli

unread,
Mar 15, 2021, 2:32:10 PM3/15/21
to Maru OS dev
Checked my code base and I have the latest one.
Still the services are not starting. Would really like about the method to fix these issues.
What I also can't understand is, that the rom is not even booting if I set selinux to permissive. Normally this should disable selinux, right?

Luka Poli

unread,
Mar 16, 2021, 4:31:15 AM3/16/21
to Maru OS dev
Good news, Maru OS (I moved to Android 10 code base) and all services are running without any flaws!
Full desktop support via ScreenShare and DisplayLink on Xiaomi Mi 8 - dipper.
I used a trick to bypass the selinux bug:

exec u:r:magisk:s0 -- /system/bin/setenforce 0

That's not beautiful, but it works for the beginning. Everything else should be fixable later!

utzcoz

unread,
Mar 16, 2021, 10:37:25 AM3/16/21
to Luka Poli, Maru OS dev
It is my method to fix SELinux problems:

1. build MaruOS with the eng variant, and it will enable adb defaultly.
2. Reboot, and use the following commands to get SELinux policy recommendations from the official tool:

adb shell dmesg | grep "avc:" > avc_log.txt
audit2allow -i avc_log.txt

Copy the result to your device sepolicy files.

If you have any questions about it, you could read the official Android SELinux documentation,
https://source.android.com/security/selinux. I learn many things from this documentation.
And hope it can be helpful for you.


Reply all
Reply to author
Forward
0 new messages