Comments (7)
@vindarel it was fixing SDL2 for a lot of people including myself. Before the change Lem failed to draw anything. SDL2 drawing operations should only be coming from a single thread. I don't think Lem has this concept which is one of the reasons why the SDL2 implementation is buggier than the curses implementation. I don't know if there is a cleaner way to fix it given the way the drawing code is written.
from lem.
Thx. People impacted were on different platforms, either on Linux than macOS or W$ ?
from lem.
I think #630 was the main thread for it. There might have been one or two other issues where people reported problems. I think everyone that posted in that thread was running a Linux variant. IIRC, Lem was using at least two threads for drawing operations. One thread has the SDL event loop and then Lem has its own event loop in another thread.
https://wiki.libsdl.org/SDL2/FAQDevelopment#can_i_call_sdl_video_functions_from_multiple_threads
from lem.
more precisely, in my case, this is slow:
;; the commit change
(sdl2:in-main-thread ()
(bt:with-recursive-lock-held ((display-mutex *display*))
(funcall function)))
this is fast:
;; before change
(defun call-with-renderer (function)
(bt:with-recursive-lock-held ((display-mutex *display*))
(funcall function)))
from lem.
This is so, so difficult. Daniel Kochmański wrote a great summary of using SDL2 as a backend for McCLIM which I'll try my best to summarize the important bits here.
The main limitation of the library is that it is not thread safe - all SDL2 functions are expected to be called from a single thread
This right here is the biggest source of problems.
lem
tries to follow McCLIM's approach of "have a singular loop and communicate with it using a thread-safe channel" but there is another caveat and that's:
Some window managers require all drawing operations to be on the main thread (usually this is macOS but it happens on some linux desktop environments, too; no idea about Windows). Combining all these clues, I'm guessing that @vindarel is experiencing some deadlock / timeout / software rendering bug.
Ultimately, I think we'll need to really hammer out the locking mechanism in lem to coordinate all the drawing operations on the main thread. (so, backing out f97c2482 isn't really a solution here
from lem.
Yeah, in an ideal world, there'd be a debug assertion where anything using SDL2 rendering could check if it's the main thread, and if not, fail fast. That would help weed out the bugs. When I was looking at it originally, it was a pretty big refactor because I think there were two different event loops and I wasn't comfortable making architectural changes that changed other UI frameworks.
from lem.
Umm given that the cause what found, should we close this issue? or the problem continues? (ping @vindarel )
from lem.
Related Issues (20)
- Lem hangs if we edit and recompile `uiop:define-package :lem-core`
- Lem hangs when using negative universal argument through M--? HOT 2
- Write the GUI in CL with McCLIM HOT 3
- How to use a custom Common Lisp implementation for Lisp code? HOT 3
- Building Lem with both SDL2 and ncurses support simultaneously HOT 3
- Top and bottom borders of SDL version (2.1.0) not visible on Windows 11
- Can't build with SDL2 on Arch Linux on WSL HOT 4
- Severe rendering performance issues with SDL2 in WSL
- cannot install on openSUSE `Package "iterate" not found` HOT 1
- Error Building Lem on MacOS Using Roswell HOT 10
- Lem on SDL2 - SBCL dropping to LDB when loading a system via ASDF. HOT 5
- Thai string is not displayed properly HOT 2
- Rounding error in mouse coordinates on SDL2 filer interface HOT 1
- Still can't build on Linux: "The archive file "cl-unicode-20210228-git.tgz" for release "cl-unicode" is missing" HOT 2
- Allow themes to modify colors of tabs and option selections HOT 3
- possibility of adding a build system that finds dependencies and builds lem with whatever it finds and whatever lisp the builder wants HOT 6
- Display scaling of HiDPI monitor is ignored, and unable to be forced
- Lisp REPL stuck in read only mode while using vi-mode HOT 2
- Missing binary files from release 2.2.0
- It seems that the :lock parameter has been removed from sbcl's defpackage. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lem.