Skip to content

When monitoring a large file with frequent writes, notepad++ locks up #9661

@JohnCalin

Description

@JohnCalin

Description of the Issue

The NPPM_INTERNAL_RELOADSCROLLTOEND message is sent every time the monitored file is updated. The handler for this message calls buf->reload() synchronously.
If writes are frequent and the file is large (or IO slow), reload() will take longer to finish than it takes for more NPPM_INTERNAL_RELOADSCROLLTOEND messages to come in. Messages received while reload() is still running are queued up.
Each message will be handled in the order received until all have completed, even after writes have stopped.

Suppose reload() takes 250ms, and 100 writes are made over 10 seconds.
Notepad++ will be unresponsive for 25 seconds (the time it takes for 100 reloads), even though writing stopped after 10 seconds.

Ideally, the message handler should only set a flag showing that a reload is needed, and then return.
A separate timer should check the flag and if set, unset it and reload the file.

Steps to Reproduce the Issue

  1. In a command prompt run the following:
    for /l %x in (1,1,1000) do echo line number %x >> testfile.txt
  2. While this runs, open the resulting testfile.txt in notepad++ and turn on file monitoring

Expected Behavior

Notepad++ should remain responsive as it updates the file, and stop reloading it once the command is finished.

Actual Behavior

Notepad++ is completely unresponsive until long after the command has finished.

Debug Information

Notepad++ v7.9.1 (64-bit)
Build time : Nov 2 2020 - 01:07:46
Path : C:\Program Files\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : OFF
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 1803
OS Build : 17134.2026
Current ANSI codepage : 1252
Plugins : mimeTools.dll NppConverter.dll NppExport.dll XMLTools.dll

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions