From nobody Wed Feb 11 01:43:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1697210350; cv=none; d=zohomail.com; s=zohoarc; b=ctZxHlRxfT/R7Oq3mwDSZZrbBaOErnjeAzf1lsBZKv49P56YFVsnfRYShqtAVGoI7NmmmW9hydgcU1DwW28Qr26q46cR42tt6uC5LwDByFQhZqSR0l84qKe0j5PdoWfJblfwckM+LDjt1mL4iVlHmMvuf2iWU0NfkObwpsXwm0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697210350; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=46yJuBQqqu6iqRoSe3GlSxMXDFd24K/OmGOw2LIUxu0=; b=UXAo9E1fK4+Zsr9q1fTmiUxf6mK1xuiHYRKqRWY0+kMxtgNsO73w4ErJ9V4GVEV7uElOf8SmczAn0uvBMrx/xySA0M4ihXNCVaYqRtjs+9xzuHHNqw06ql1rgXy2WpHakxoNKquhM/sfX8FH5W1s52NTCf8mkpB97oCqXx8ZLuA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169721035043051.32950811621129; Fri, 13 Oct 2023 08:19:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrJvW-0006jW-3G; Fri, 13 Oct 2023 11:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrJvU-0006cI-7e for qemu-devel@nongnu.org; Fri, 13 Oct 2023 11:18:08 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrJvS-0000R9-Ev for qemu-devel@nongnu.org; Fri, 13 Oct 2023 11:18:07 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39DDMNtE009812; Fri, 13 Oct 2023 15:18:03 GMT Received: from euamsppmta02.qualcomm.com ([212.136.9.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tpt0x217n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 15:18:03 +0000 Received: from pps.filterd (EUAMSPPMTA02.qualcomm.com [127.0.0.1]) by EUAMSPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 39DFI0IR031874; Fri, 13 Oct 2023 15:18:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by EUAMSPPMTA02.qualcomm.com (PPS) with ESMTPS id 3tk0dmta05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 15:18:00 +0000 Received: from EUAMSPPMTA02.qualcomm.com (EUAMSPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 39DFI02q031851; Fri, 13 Oct 2023 15:18:00 GMT Received: from hu-devc-ams-u20-c.qualcomm.com (hu-acaggian-ams.qualcomm.com [10.251.153.136]) by EUAMSPPMTA02.qualcomm.com (PPS) with ESMTPS id 39DFI0AC031850 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Oct 2023 15:18:00 +0000 Received: by hu-devc-ams-u20-c.qualcomm.com (Postfix, from userid 4298557) id 6193720CB2; Fri, 13 Oct 2023 17:18:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=qcppdkim1; bh=46yJuBQqqu6iqRoSe3GlSxMXDFd24K/OmGOw2LIUxu0=; b=QL/I8WUE8XbFy07UJksYA+Z5VluSmQIwUa9I6ZWMfo9H/JJB9ZFjTnbj4Ou4o7Oj08fZ htapM8E5pqNeHeFUdJ7UhoVFFHf8SxClntJdUYeKwm7tNkBGbK7AbOFeB59Son3/O8qq NAvskzCuTat06fLrXO76wxVn7WZIZ/+sqcrytIIw//Sg5XKhIA31EUnmFdWLb/fKDWJM ufkfxpBw/sRDD6iO8OhAAz/Wgao1BuznNaMok6vYMNe7giieCMWq/qu7wsXNdeSPYpxS bmJiNZbWe5G26vkUPtMJobSYSoeotNnYeJt5UGlSCudY/kiKF5O8x27N/fjtAcO2hbPZ 6g== From: Antonio Caggiano To: Cc: Antonio Caggiano , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org (open list:All patches CC here) Subject: [PATCH] ui/gtk-egl: Check EGLSurface before doing scanout Date: Fri, 13 Oct 2023 17:17:58 +0200 Message-Id: <20231013151758.1472603-1-quic_acaggian@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: uF98wfnITUqpSmocEFfsPCQnF8PUs8MG X-Proofpoint-ORIG-GUID: uF98wfnITUqpSmocEFfsPCQnF8PUs8MG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-13_06,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 mlxscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=555 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310130129 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=acaggian@qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1697210352384100003 Content-Type: text/plain; charset="utf-8" The first time gd_egl_scanout_texture() is called, there's a possibility that the GTK drawing area might not be realized yet, in which case its associated GdkWindow is NULL. This means gd_egl_init() was also skipped and the EGLContext and EGLSurface stored in the VirtualGfxConsole are not valid yet. Continuing with the scanout in this conditions would result in hitting an assert in libepoxy: "Couldn't find current GLX or EGL context". A possible workaround is to just ignore the scanout request, giving the the GTK drawing area some time to finish its realization. At that point, the gd_egl_init() will succeed and the EGLContext and EGLSurface stored in the VirtualGfxConsole will be valid. Signed-off-by: Antonio Caggiano Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-egl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index a1060fd80f..2eefcd2cf4 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -243,12 +243,19 @@ void gd_egl_scanout_texture(DisplayChangeListener *dc= l, vc->gfx.h =3D h; vc->gfx.y0_top =3D backing_y_0_top; =20 - eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, - vc->gfx.esurface, vc->gfx.ectx); + if (!vc->gfx.esurface) { + gd_egl_init(vc); + if (!vc->gfx.esurface) { + return; + } =20 - gtk_egl_set_scanout_mode(vc, true); - egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, - backing_id, false); + eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, + vc->gfx.esurface, vc->gfx.ectx); + =20 + gtk_egl_set_scanout_mode(vc, true); + egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_hei= ght, + backing_id, false); + } } =20 void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, --=20 2.25.1