fix(wayland): segfault because of double free surfaces (#34752)

* Fix segfault because of double free surfaces

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Add warn log if glvideo is enabled on headless

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Add FIXME comment

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-12-24 15:47:38 +09:00 committed by GitHub
parent d8b7195c75
commit ff7626bfc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 26 deletions

View file

@ -2,15 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::rc::Rc;
use std::{env, panic, process};
use getopts::Options;
use log::error;
use log::{error, warn};
use servo::config::opts::{self, ArgumentParsingResult};
use servo::config::set_pref;
use servo::servo_config::pref;
use super::events_loop::EventsLoop;
use crate::desktop::app::App;
use crate::desktop::events_loop::EventsLoop;
use crate::desktop::{headed_window, headless_window};
use crate::panic_hook;
pub fn main() {
@ -103,10 +106,27 @@ pub fn main() {
let event_loop = EventsLoop::new(opts::get().headless, opts::get().output_file.is_some())
.expect("Failed to create events loop");
// Implements window methods, used by compositor.
// FIXME: We keep the window until application exits. Otherwise, it will cause
// simthay-clipboard thread segfault on Wayland.
let window = if opts::get().headless {
if pref!(media.glvideo.enabled) {
warn!("GL video rendering is not supported on headless windows.");
set_pref!(media.glvideo.enabled, false);
}
headless_window::Window::new(opts::get().initial_window_size, device_pixel_ratio_override)
} else {
Rc::new(headed_window::Window::new(
opts::get().initial_window_size,
event_loop.as_winit(),
do_not_use_native_titlebar,
device_pixel_ratio_override,
))
};
let mut app = App::new(
&event_loop,
do_not_use_native_titlebar,
device_pixel_ratio_override,
window.clone(),
user_agent,
url_opt.map(|s| s.to_string()),
);