lvgl / lv_port_linux

LVGL configured to work with a standard Linux framebuffer
MIT License
260 stars 160 forks source link

Segmentation fault when running demo app with rotation of LV_DISP_ROT_270 #13

Closed bigbearishappy closed 2 years ago

bigbearishappy commented 3 years ago

Hello. I have make the lvgl demo work on my raspberrypi CM4 module. When I rotate the app for 0 or 180 degrees.It works fine. But when I rotate it for 90 or 270 degrees.It break when I touch some place of the touch panel. the log shows:"Segmentation fault"

I also have done some debug work for it.I find that when the error happens. The log int drm_flush shows that the value of w is negative.

Is there anyway I can fix this error? I will be appreciated if someone can help me out.

bigbearishappy commented 3 years ago

This is the log when the error happens:

drm: flip drm: Find plane property: FB_ID drm: Find plane property: FB_ID drm: Find plane property: CRTC_ID drm: Find plane property: CRTC_ID drm: Find plane property: SRC_X drm: Find plane property: SRC_X drm: Find plane property: SRC_Y drm: Find plane property: SRC_Y drm: Find plane property: SRC_W drm: Find plane property: SRC_W drm: Find plane property: SRC_H drm: Find plane property: SRC_H drm: Find plane property: CRTC_X drm: Find plane property: CRTC_X drm: Find plane property: CRTC_Y drm: Find plane property: CRTC_Y drm: Find plane property: CRTC_W drm: Find plane property: CRTC_W drm: Find plane property: CRTC_H drm: Find plane property: CRTC_H drm: Flush done drm: x 6551:406 y 55:58 w -6144 h 4 Segmentation fault

kisvegabor commented 3 years ago

Can you reproduce it in a simulator on a simple UI (i.e. with a single button or so)?

bigbearishappy commented 3 years ago

Can you reproduce it in a simulator on a simple UI (i.e. with a single button or so)?

OK, I'll try that and tell you the result.

bigbearishappy commented 3 years ago

Can you reproduce it in a simulator on a simple UI (i.e. with a single button or so)?

Hello,I have test the single button(lv_example_keyboard_1) and it works fine in all orientation. but when I test the keyboard(lv_example_keyboard_1).I can reproduce the app break after I touch the touch panel for several times. And I attach my patch file for this project.Maybe it's helpful for you. lvgl_patch.zip

kisvegabor commented 3 years ago

For easier review, could you send Pull request with the suggested fixes?

bigbearishappy commented 3 years ago

For easier review, could you send Pull request with the suggested fixes?

I'm sorry.The file lvgl_patch.zip is to apply for adapting to my own hardware.It can not fix this problem.

kisvegabor commented 3 years ago

Oh, I was too optimistic. I thought patch to fix the problem :slightly_smiling_face:

I've tested lv_examples_keyboard_1 with 270 degree rotation and noticed a glitch. It wasn't crashing for me but that glitch can be the sign of the same problem. See the blinking cursor here: t

The software rotation was written by @embeddedt. Hopefully he can take look at it and spot the problem easily.

embeddedt commented 3 years ago

@kisvegabor I will have to look into it in more detail later, however, from a quick debugging session, the issue seems to be related to my optimization here, where I try to rotate the top chunk as a square to save memory and time. For some reason this seems to result in only half of the cursor being drawn correctly each time it blinks.

If you disable that optimization by prepending false && to the if statement, the issue only appears the first time you click the keyboard (you see half of the cursor appearing rather than the full cursor), but it immediately corrects itself afterwards.

It's strange that this is only affecting the cursor and not anything else on the screen.

kisvegabor commented 3 years ago

I made some test with a slightly modified lv_example_btn_1(). Adding false to the mentioned if doesn't make much difference. r

embeddedt commented 3 years ago

@kisvegabor True. Thanks for finding that reproduction case, it's a lot easier to control than the text area's cursor.

I think it's an issue with the SDL driver, not LVGL. I added a lot of debug statements locally and the last chunk (the one which lags behind by a frame) is definitely being sent to flush_cb. I also modified flush_cb to render a different solid color for each new frame, thus ignoring whatever bitmap data LVGL produces, and I can see the same issue where the last section is staying as the previous color instead of being redrawn. So I don't think the rotation logic is responsible for this glitch, though it is definitely an issue. I still don't know exactly why it's happening only when the screen is rotated by 90 degrees.

I also ran the exact same code on STM32 and didn't see any problems there at all.

bigbearishappy commented 3 years ago

Oh, I was too optimistic. I thought patch to fix the problem 🙂

I've tested lv_examples_keyboard_1 with 270 degree rotation and noticed a glitch. It wasn't crashing for me but that glitch can be the sign of the same problem. See the blinking cursor here: t

The software rotation was written by @embeddedt. Hopefully he can take look at it and spot the problem easily.

Yes, when I have observed the abnormality carefully. I find this glitch on my machine too. Everytime I touch the textarea of the example, the glitch happens. and then my app breaks. Also, I tried to simplify the code of lv_example_keyboard_1 with deleting the keyboard in it. I can reproduce the glitch by touch the textarea too.

bigbearishappy commented 3 years ago

@kisvegabor I will have to look into it in more detail later, however, from a quick debugging session, the issue seems to be related to my optimization here, where I try to rotate the top chunk as a square to save memory and time. For some reason this seems to result in only half of the cursor being drawn correctly each time it blinks.

If you disable that optimization by prepending false && to the if statement, the issue only appears the first time you click the keyboard (you see half of the cursor appearing rather than the full cursor), but it immediately corrects itself afterwards.

It's strange that this is only affecting the cursor and not anything else on the screen.

@kisvegabor I will have to look into it in more detail later, however, from a quick debugging session, the issue seems to be related to my optimization here, where I try to rotate the top chunk as a square to save memory and time. For some reason this seems to result in only half of the cursor being drawn correctly each time it blinks.

If you disable that optimization by prepending false && to the if statement, the issue only appears the first time you click the keyboard (you see half of the cursor appearing rather than the full cursor), but it immediately corrects itself afterwards.

It's strange that this is only affecting the cursor and not anything else on the screen.

I also tried adding false && to the if statement.The app still breaked.

bigbearishappy commented 3 years ago

In my opinion. It should be something wrong with the coordinate calculation.

kisvegabor commented 3 years ago

I found the issue of incorrect cursor refresh. See here: https://github.com/lvgl/lvgl/commit/c514bddd9b4064e2eba0c3ec4c7a51415acd74e4

The flushing_last flag wasn't set therefore SDL didn't update the texture.

Probably it won't solve the issue of @bigbearishappy but let's give it a try :)

bigbearishappy commented 3 years ago

I found the issue of incorrect cursor refresh. See here: lvgl/lvgl@c514bdd

The flushing_last flag wasn't set therefore SDL didn't update the texture.

Probably it won't solve the issue of @bigbearishappy but let's give it a try :)

Cool, I'll try it next Monday.Thank you.

bigbearishappy commented 3 years ago

I found the issue of incorrect cursor refresh. See here: lvgl/lvgl@c514bdd

The flushing_last flag wasn't set therefore SDL didn't update the texture.

Probably it won't solve the issue of @bigbearishappy but let's give it a try :)

I have apply the patch and test on my machine. But the changes can not solve this issue. The break happens as it used to be.

kisvegabor commented 3 years ago

Can you debug the project to see how that weird area is calculated?

bigbearishappy commented 3 years ago

Can you debug the project to see how that weird area is calculated?

OK,I'll have a try and reply to you.

stale[bot] commented 2 years ago

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.