[CLOSED] Regex evaluation freezes the browser

  1. #1

    [CLOSED] Regex evaluation freezes the browser

    Hi,

    Regex evaluation execution hangs on my page when entering invalid characters under certain circumstances. I'm using IE9 to test. Please consider the basic code sample below and follow these steps to reproduce the issue:

    • Start Task Manager
    • Click on the button to bring up the modal window
    • Place the cursor inside the text box
    • Complete the word "document" in the text box
    • Observe no issue with Regex evaluation processing time and CPU usage
    • Place the cursor at the end of the text string
    • Type in a backslash or ampersand character
    • Notice a slight delay in evaluation and a spike in CPU cycles


    The problem is much more pronounced in my application whereby the page hosting the modal window is loaded with other controls and client side code. Sometimes, it takes close to a minute for the browser to "unfreeze" after Regex evaluation. Please suggest what maybe the cause.

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" SourceFormatting="True"
            ScriptMode="Debug" />
        <ext:Window ID="Window1" runat="server" Title="Hello World!" Icon="Application" Height="400px"
            Width="600px" BodyStyle="background-color: #fff;" Padding="5" Collapsible="true"
            Hidden="true" Modal="true">
            <Items>
                <ext:ColumnLayout ID="ColumnLayout1" runat="server" Split="false" FitHeight="true">
                    <Columns>
                        <ext:LayoutColumn ColumnWidth="0.25">
                            <ext:Panel ID="Panel1" runat="server" Html="<div style='font-weight:bold;font-size:9pt;margin:5px;margin-top:27px;'>Select the Title for this new document:</div>"
                                BodyCssClass="my-panel-body" />
                        </ext:LayoutColumn>
                        <ext:LayoutColumn ColumnWidth="0.75">
                            <ext:Panel ID="Panel2" runat="server" Border="true" Frame="false" Layout="FormLayout"
                                Padding="24">
                                <Items>
                                    <ext:TextField runat="server" ID="TextFieldDocumentTitle" AnchorHorizontal="100%"
                                        FieldLabel="Input text" Text="24 pages doc OCR-ed" Width="300" SelectOnFocus="true"
                                        Regex="^([^&amp;/?*:\&quot;|<>\\]+)+$" RegexText="Invalid Document Title" AllowBlank="false"
                                        BlankText="<nobr>Document Title is required</nobr>">
                                    </ext:TextField>
                                </Items>
                            </ext:Panel>
                        </ext:LayoutColumn>
                    </Columns>
                </ext:ColumnLayout>
            </Items>
        </ext:Window>
        <ext:Button runat="server" Text="Show Window">
            <Listeners>
                <Click Handler="Window1.show();" />
            </Listeners>
        </ext:Button>
    </body>
    </html>
    Last edited by Daniil; Feb 05, 2013 at 10:08 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Unfortunately, I couldn't reproduce your problem or even see some lags. It's difficult to anything without more complected example, can you provide it?
  3. #3
    It's consistently reproducible in IE9 when I follow the steps. The lag time varies but the delay is palpable accompanied by 10% spike in CPU cycles. Try to complete the word "document" and then append the ampersand to the end of string to see the delay. Remove it and then put after the word "document". This time round, there will be no lag.
    Last edited by vadym.f; Feb 05, 2013 at 2:09 AM.
  4. #4
    Hello everybody,

    I reproduce the issue. IE can just hang on.

    I am afraid it is a weak place in the IE JavaScript engine. I doubt it is related to either ExtJS or Ext.NET.

    I see a small (very small) delay even in Chrome and FireFox. It is insignificant comparing with IE lag, but it led me to the thought - maybe, there is a way to optimize your expression. Though it doesn't look difficult.

    We just discovered that it is also reproducible with Ext.NET v2. I reported here. Even if it is not an ExtJS bug, there is a chance that they could suggest something.
    http://www.sencha.com/forum/showthread.php?255643
  5. #5
    There are interesting answers in the Sehcna thread. Please read.

    Marking the thread closed if you don't mind. But posting any information about any progress on this issue would be appreciated.
  6. #6
    Many thanks for digging it up Daniil!! I appreciate all the great insights into this problem. After simplifying the Regex as suggested, there're no significant performance issues to report so far (fingers crossed). Since I'm not really up to the task of fine tuning the JS engine, I'll take the working suggestion any day of the week. :)

    <ext:TextField runat="server" ID="TextFieldDocumentTitle" AnchorHorizontal="100%"
               FieldLabel="Input text" Text="24 pages doc OCR-ed" Width="300" SelectOnFocus="true"
               Regex="^[^&amp;/?*:\&quot;|<>\\]+$" RegexText="Invalid Document Title" AllowBlank="false"
               BlankText="<nobr>Document Title is required</nobr>">
    </ext:TextField>

Similar Threads

  1. Replies: 1
    Last Post: Sep 30, 2011, 11:15 AM
  2. [CLOSED] Freezes summary row for gridpanel
    By yobnet in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Sep 15, 2010, 6:24 PM
  3. Regex not compiled
    By ATSistemi in forum Open Discussions
    Replies: 2
    Last Post: May 26, 2010, 2:15 PM
  4. REGEX
    By hbbazan in forum 1.x Help
    Replies: 0
    Last Post: Jan 27, 2010, 4:09 PM
  5. [CLOSED] RegEx problem
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 28, 2009, 12:08 PM

Tags for this Thread

Posting Permissions