Re: wxPython 4/wx.Yield: C++ assert failure
James Teh <[email protected]>
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi. I'm the NVDA developer Joseph was discussing this with. First, my thanks to all who have helped with this so far. Even though I totally understand that wx.Yield can cause re-entrance (this is clearly documented), this wasn't previously the case when starting the same timer within that timer's callback. That is, *another* timer or a wx event might get fired within wx.Yield, but the *same* timer never fired. Instead, the inner call to the timer was dropped. That is what this test case demonstrates. In wxPython 3, you never see the re-entrance message. In wxPython 4, you do. The question is whether this change is intentional/expected and whether the previous behaviour will be restored. It's reasonable to argue that we were relying on undefined behaviour (or maybe even a bug), and if that is the case and this won't be reverted, we'll find another way. However, I wanted to confirm this before putting a huge amount of work into "fixing" this. The reason we use wx.Yield here is that we need to trigger a Windows message pump when sending key presses and checking for pending accessibility events, since keyboard events and accessibility events depend on the Windows message queue. I guess we could just do our own message pump, but I'm concerned this would end up processing wx events anyway. Thanks! Jamie On Friday, April 28, 2017 at 4:30:44 AM UTC+10, [email protected] wrote: > > Hi Joseph, > > > > The NVDA developer is likely correct, but your example shows expected > behavior, not a bug. You're adding an infinite number of timer events, then > calling wx.Yield in them. This will cause infinite recursion, as wx.Yield > will process the next timer event, which will call wx.Yield, which will > process the next timer event, which will call wx.Yield, and so on. I don't > think a change in wx.Yield is at fault here, it's just alerting you to the > recursion instead of causing it. To get to the bottom of this, you'll need > to find out what is triggering the recursion in NVDA. > > > > Taking a quick look at the NVDA code's use of wx.Yield, I think the first > step would probably be to find out if api.py's processPendingEvents is > somehow calling itself multiple times. If you can identify the specific set > of steps that trigger recursion, the NVDA developers will probably be able > to come up with some ideas for workarounds or fixes. > > > > Regards, > > > > Kevin > > > > *From: *<[email protected] <javascript:>> on behalf of Joseph > Lee <[email protected] <javascript:>> > *Reply-To: *<[email protected] <javascript:>> > *Date: *Thursday, April 27, 2017 at 9:36 AM > *To: *<[email protected] <javascript:>> > *Subject: *RE: [wxPython-dev] wxPython 4/wx.Yield: C++ assert failure > > > > Hi Robin, > > At least wx.YieldIfNeeded suppresses the assertions. However, according to > a lead NVDA developer, this does not really resolve this problem, as NVDA > needs to handle other events external to wxWidgets such as accessibility > events. The lead developer (not me) believes that the root problem might > have to do with timers and certain things that are internally different > between wxPython classic and phoenix. > > Can you try out this example and see if we can trace this: > > https://www.dropbox.com/s/p8uuf52hzlmyd3x/wxReentrance.py?dl=1 > > > > Note that the example requires Python 2.7 with wxPython 4.0.0A1. Thanks. > > Cheers, > > Joseph > > > > *From:* [email protected] <javascript:> [mailto: > [email protected] <javascript:>] *On Behalf Of *Robin Dunn > *Sent:* Thursday, April 27, 2017 12:17 AM > *To:* [email protected] <javascript:> > *Subject:* Re: [wxPython-dev] wxPython 4/wx.Yield: C++ assert failure > > > > Joseph Lee wrote: > > > Hi Robin and others, > > > > In one of the projects I’m involved in (NonVisual Desktop Access), > numerous calls to wx.Yield function are made from various modules. After > porting NVDA to wxPython 4 alpha, when wx.Yield is called from some > modules, I get a traceback that ends with the following: > > wxAssertionError: C++ assertion "Assert failure" failed at > ..\..\src\common\evtloopcmn.cpp(110) in wxEventLoopBase::Yield(): wxYield > called recursively > > > > Relevant GitHub issue for NVDA can be found at: > > https://github.com/nvaccess/nvda/issues/7077 > > > > The source code for a version of NVDA that uses wxPython 4 can be found at: > > https://github.com/josephsl/nvda > > > > Branch is “wxPy4”. I and other NVDA developers involved in porting NVDA to > wxPython 4 consider this a showstopper, with a lead developer commenting > that this might be due to reentrancy issue. > > > Yes. Basically some event(s) happens while within a wx.Yield call which > then results in some other code being called that uses wx.Yield. > > The best fix would be to find ways to avoid needing to use yield. > Otherwise you could switch to wx.YieldIfNeeded() (which is just a > convenience wrapper for wx.GetApp().Yield(True)...) That will just return > when the recursion is detected instead of asserting about it. The > wx.EventLoopBase.Yield documentation is applicable to this as all the > incarnations of Yield eventually get to that method. > > > -- > Robin Dunn > Software Craftsman > http://wxPython.org > > -- > You received this message because you are subscribed to the Google Groups > "wxPython-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "wxPython-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "wxPython-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.