Drag and drop does not work with the wayland backend #99737

Closed
opened 2022-07-15 15:11:26 +02:00 by Sebastian Parborg · 8 comments

System Information
Operating system: Gentoo Linux
Graphics card: AMD Vega

Blender Version
Broken: master
Worked: -

Short description of error
When dragging and dropping files from outside of Blender, it almost always fails (nothing happens).
See video below. (Drag and dropping into GIMP and other wayland applications seem to work flawlessly)
rec_30.mp4

It seems like Blender does sometimes detect that something is dropped into it as this is printed into the terminal:

I haven't tried any other window manager but Sway. However I think that Blender might be violating the specs here somehow and that is why things are weird.
Here is a blog post from one of the wlroots developers on how the clipboard and drag and drop works in wayland: https://emersion.fr/blog/2020/wayland-clipboard-drag-and-drop/

drop file /home/zed/elkfinal.png
drop file /home/zed/elkfinal.png
drop file /home/zed/elkfinal.png
drop file /home/zed/elkfinal.png
drop file /home/zed/elkfinal.png

In the rare case that the drag and drop works, the image in this case is not dropped where the mouse cursor is, but in an other location.
IE the mouse could be in the left corner of the 3D view, but the image is inserted on the right corner instead.

Exact steps for others to reproduce the error

  1. Open Blender running the wayland backend
  2. Try to drag an image into the 3D view from an other program.
  3. Notice how it is flaky and doesn't work most of the time.
**System Information** Operating system: Gentoo Linux Graphics card: AMD Vega **Blender Version** Broken: master Worked: - **Short description of error** When dragging and dropping files from outside of Blender, it almost always fails (nothing happens). See video below. (Drag and dropping into GIMP and other wayland applications seem to work flawlessly) [rec_30.mp4](https://archive.blender.org/developer/F13294800/rec_30.mp4) It seems like Blender does sometimes detect that something is dropped into it as this is printed into the terminal: I haven't tried any other window manager but Sway. However I think that Blender might be violating the specs here somehow and that is why things are weird. Here is a blog post from one of the wlroots developers on how the clipboard and drag and drop works in wayland: https://emersion.fr/blog/2020/wayland-clipboard-drag-and-drop/ ``` drop file /home/zed/elkfinal.png drop file /home/zed/elkfinal.png drop file /home/zed/elkfinal.png drop file /home/zed/elkfinal.png drop file /home/zed/elkfinal.png ``` In the rare case that the drag and drop works, the image in this case is not dropped where the mouse cursor is, but in an other location. IE the mouse could be in the left corner of the 3D view, but the image is inserted on the right corner instead. **Exact steps for others to reproduce the error** 1. Open Blender running the wayland backend 2. Try to drag an image into the 3D view from an other program. 3. Notice how it is flaky and doesn't work most of the time.
Author
Member

Added subscriber: @ZedDB

Added subscriber: @ZedDB
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Campbell Barton was assigned by Sebastian Parborg 2022-07-15 15:12:00 +02:00

This issue was referenced by bbf87c4f75

This issue was referenced by bbf87c4f750992f47f514733e3a7d33573f5c860

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Author
Member

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'
Author
Member

This seems to still not be fixed.

I've tried it with latest sway master and there seems to work with GTK3 clients, sometimes.
With QT5 clients (pcmanfm-qt) it is still is not working.

I'm guessing that there are some race condition going on as ASAN also regularly shuts down Blender when I try to drag and drop with:

==24348==ERROR: AddressSanitizer: heap-use-after-free on address 0x608000d27460 at pc 0x000010bbe835 bp 0x7ffb7895aa40 sp 0x7ffb7895aa30
READ of size 8 at 0x608000d27460 thread T23
    - 0 0x10bbe834 in operator() /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1217
    - 1 0x10bf3b30 in __invoke_impl<void, data_device_handle_drop(void*, wl_data_device*)::<lambda(input_t*, data_offer_t*, wl_surface*, std::string)>, input_t*, data_offer_t*, wl_surface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/invoke.h:61
    - 2 0x10bf370e in __invoke<data_device_handle_drop(void*, wl_data_device*)::<lambda(input_t*, data_offer_t*, wl_surface*, std::string)>, input_t*, data_offer_t*, wl_surface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/invoke.h:96
    - 3 0x10bf3110 in _M_invoke<0, 1, 2, 3, 4> /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/std_thread.h:253
    - 4 0x10bf2d40 in operator() /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/std_thread.h:260
    - 5 0x10bf2cd0 in _M_run /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/std_thread.h:211
    - 6 0x7ffbb3625f3f  (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libstdc++.so.6+0xd4f3f)
    - 7 0x7ffbb330a496 in start_thread /var/tmp/portage/sys-libs/glibc-2.34-r13/work/glibc-2.34/nptl/pthread_create.c:435
    #8 0x7ffbb338c37b  (/lib64/libc.so.6+0x10937b)

0x608000d27460 is located 64 bytes inside of 88-byte region [0x608000d27420,0x608000d27478)
freed by thread T0 here:
    - 0 0x7ffbc86210e7 in operator delete(void*, unsigned long) (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libasan.so.6+0xb50e7)
    - 1 0x10bbde9c in data_device_handle_leave /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1173
    #2 0x7ffbaf166e29  (/usr/lib64/libffi.so.8+0x6e29)

previously allocated by thread T0 here:
    - 0 0x7ffbc8620087 in operator new(unsigned long) (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libasan.so.6+0xb4087)
    - 1 0x10bbcd33 in data_device_handle_data_offer /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1119
    #2 0x7ffbaf166e29  (/usr/lib64/libffi.so.8+0x6e29)

Thread T23 created by T0 here:
    - 0 0x7ffbc85c3571 in pthread_create (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libasan.so.6+0x57571)
    - 1 0x7ffbb3626004 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libstdc++.so.6+0xd5004)
    - 2 0x10bbfdc5 in data_device_handle_drop /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1272
    - 3 0x7ffbaf166e29  (/usr/lib64/libffi.so.8+0x6e29)

So I'm guessing that there is some non thread safe stuff happening in Blender that makes it sometimes not work and sometimes we get this "use after free" error.

I'm getting a similar "use after free" error when exiting Blender as well.

This seems to still not be fixed. I've tried it with latest sway master and there seems to work with GTK3 clients, sometimes. With QT5 clients (pcmanfm-qt) it is still is not working. I'm guessing that there are some race condition going on as ASAN also regularly shuts down Blender when I try to drag and drop with: ``` ==24348==ERROR: AddressSanitizer: heap-use-after-free on address 0x608000d27460 at pc 0x000010bbe835 bp 0x7ffb7895aa40 sp 0x7ffb7895aa30 READ of size 8 at 0x608000d27460 thread T23 - 0 0x10bbe834 in operator() /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1217 - 1 0x10bf3b30 in __invoke_impl<void, data_device_handle_drop(void*, wl_data_device*)::<lambda(input_t*, data_offer_t*, wl_surface*, std::string)>, input_t*, data_offer_t*, wl_surface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/invoke.h:61 - 2 0x10bf370e in __invoke<data_device_handle_drop(void*, wl_data_device*)::<lambda(input_t*, data_offer_t*, wl_surface*, std::string)>, input_t*, data_offer_t*, wl_surface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/invoke.h:96 - 3 0x10bf3110 in _M_invoke<0, 1, 2, 3, 4> /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/std_thread.h:253 - 4 0x10bf2d40 in operator() /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/std_thread.h:260 - 5 0x10bf2cd0 in _M_run /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/std_thread.h:211 - 6 0x7ffbb3625f3f (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libstdc++.so.6+0xd4f3f) - 7 0x7ffbb330a496 in start_thread /var/tmp/portage/sys-libs/glibc-2.34-r13/work/glibc-2.34/nptl/pthread_create.c:435 #8 0x7ffbb338c37b (/lib64/libc.so.6+0x10937b) 0x608000d27460 is located 64 bytes inside of 88-byte region [0x608000d27420,0x608000d27478) freed by thread T0 here: - 0 0x7ffbc86210e7 in operator delete(void*, unsigned long) (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libasan.so.6+0xb50e7) - 1 0x10bbde9c in data_device_handle_leave /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1173 #2 0x7ffbaf166e29 (/usr/lib64/libffi.so.8+0x6e29) previously allocated by thread T0 here: - 0 0x7ffbc8620087 in operator new(unsigned long) (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libasan.so.6+0xb4087) - 1 0x10bbcd33 in data_device_handle_data_offer /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1119 #2 0x7ffbaf166e29 (/usr/lib64/libffi.so.8+0x6e29) Thread T23 created by T0 here: - 0 0x7ffbc85c3571 in pthread_create (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libasan.so.6+0x57571) - 1 0x7ffbb3626004 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libstdc++.so.6+0xd5004) - 2 0x10bbfdc5 in data_device_handle_drop /home/zed/prog/blender/intern/ghost/intern/GHOST_SystemWayland.cpp:1272 - 3 0x7ffbaf166e29 (/usr/lib64/libffi.so.8+0x6e29) ``` So I'm guessing that there is some non thread safe stuff happening in Blender that makes it sometimes not work and sometimes we get this "use after free" error. I'm getting a similar "use after free" error when exiting Blender as well.
Fixed 727cc426bc & a95103f6f4.

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#99737
No description provided.