react-diff-viewer icon indicating copy to clipboard operation
react-diff-viewer copied to clipboard

Handle large files

Open praneshr opened this issue 5 years ago • 20 comments

Try introducing the windowing technique to handle large DOM nodes.

praneshr avatar Aug 16 '19 12:08 praneshr

Encounter the same problem,looking forward optimization~

taeyangee avatar Nov 08 '19 09:11 taeyangee

I need to diff large text(145k) with 90% difference, but actually the browser crashed when rendering large text. I'm also looking forward your optimization~

cczz598 avatar Dec 06 '19 03:12 cczz598

How long does it take

skyunBoss avatar Dec 16 '19 06:12 skyunBoss

@skyunBoss - I don't have a timeline for it. I'm experimenting with few techniques. But, I'll address this issue soon!

praneshr avatar Dec 17 '19 07:12 praneshr

Would the use of a web worker help? https://developer.mozilla.org/fr/docs/Web/API/Web_Workers_API

Azrog avatar Mar 27 '20 08:03 Azrog

@praneshr I also have to support large diffs and my temporary solution is to display a spinner and put a message that this may take a while if the changeset is huge 😂.

Have you thought about using react-virtual (https://github.com/tannerlinsley/react-virtual) to solve the issue? Here's examples of using react-virtual https://codesandbox.io/s/github/tannerlinsley/react-virtual/tree/master/examples/sandbox.

SamSamskies avatar May 09 '20 17:05 SamSamskies

@SamSamskies Thanks for the comment. Yes, I've explored the windowing option. But, I don't have the bandwidth to work on it now. So, I cannot guarantee a release date. Sorry.

praneshr avatar May 10 '20 09:05 praneshr

@praneshr np. I'll try and take a crack at it if I get some bandwidth myself.

SamSamskies avatar May 10 '20 20:05 SamSamskies

Would the use of a web worker help? https://developer.mozilla.org/fr/docs/Web/API/Web_Workers_API

I think the main problem is the number of DOM nodes generated for large diffs, so I don't think web workers would help much.

SamSamskies avatar May 10 '20 20:05 SamSamskies

I am guessing that the problem stems from the "diff" library in the dependencies. It has the same unsolved issue with large diffs -> https://github.com/kpdecker/jsdiff/issues/163

I suggest using https://github.com/google/diff-match-patch for handling large diffs

souljuse avatar Jan 05 '21 08:01 souljuse

Is there are progress on this one ?

josephwaiguru avatar Mar 31 '21 08:03 josephwaiguru

I'm hitting this one as well on a diff between two 3kb strings. The page essentially freezes and must be killed by the browser's task manager. The problem is definitely in the diff library (not this one), so I think it would be better to switch to another diff library.

hperrin avatar May 10 '21 18:05 hperrin

Check out this package: https://www.npmjs.com/package/diff-match-patch

You can essentially get the same characteristics using diff_main as a substitute for "character" diffing, and diff_cleanupSemantic on the resulting diff for "word" diffing.

Since you first operate on a line diff though, you'll need this part: https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs

There is also a section in there about actual word diff mode, if using the semantic cleanup is not appropriate.

hperrin avatar May 10 '21 18:05 hperrin

Would have liked to use this package, but I need this feature. Had to find another solution.

lordprana avatar Aug 25 '22 18:08 lordprana

Any updates on it. Or any one got an alternate solution for it.

gladsonrobinson avatar Sep 05 '22 17:09 gladsonrobinson

@lordprana Have you find any solution for the large data?

gladsonrobinson avatar Sep 05 '22 17:09 gladsonrobinson

So I figured that if you use json.Stringify(jsonstr, null, 2) to format the string first and then use json diff viewer then it's faster to compare.

usutaria avatar May 15 '23 18:05 usutaria

One can also try react-diff-viewer-continued along with json string formatted for new line using json.stringify(jsonstr, null, 2).

usutaria avatar May 15 '23 19:05 usutaria

Any progress on this issue?

m-s-abeer avatar Oct 31 '23 04:10 m-s-abeer

I am guessing that the problem stems from the "diff" library in the dependencies. It has the same unsolved issue with large diffs -> kpdecker/jsdiff#163

I suggest using https://github.com/google/diff-match-patch for handling large diffs

It looks like someone potentially fixed the issue and a new release is in the works though the owner of that library doesn't seem to be all that active either.

This library would then need to be updated with it, but seeing as @praneshr doesn't seem to be working on this anymore, there might be more luck hoping for an update to the forked react-diff-viewer-continued instead.

jfaMan avatar Jan 17 '24 23:01 jfaMan