obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Bug report: excessive refreshing

Open imeed166 opened this issue 2 years ago • 15 comments

What happened?

the query refreshes too much, when editing a file in another pane.

https://user-images.githubusercontent.com/38974541/167502627-87a7b1b2-78cf-4fe9-87e2-01caafb38600.mov

DQL

No response

JS

let text
let groups = dv.pages('#project')
	.where(p => p.date?.toISODate() != time && !p.file.path.includes('templates'))
	.sort(p => p.impact)
	.sort(p => p.class, 'desc')
	.sort(p => p.deadline)
	.sort(p => p.file.tasks.completed.includes(false),'desc')
	.sort(p => p.date?.toISODate() > time)
	.groupBy(p => p.theme)

for (let group of groups.sort(g => g.key, 'desc')) {
	if (!group.key) {
		dv.header(4, 'ST')
	} else {
		dv.header(4, group.key)	
	}
	dv.list(group.rows.map(t => {
		if (!t.file.tasks.completed.includes(false)) {
			text =  '☑️ ' + t.file.link
		} else if (t.file.tasks.completed.includes(false) && (t.date?.toISODate() <= time) || !t.date) {
			text = '⛓ ' + t.file.link
		} else if (t.date?.toISODate() > time) {
			text = '🗓 ' + t.file.link
		} else {
			text = t.file.link
		}
		if (t.deadline !== null) {
			text = text + " (" + Math.ceil(t.deadline.diff(DateTime.now()).as('days')) + ")"
		}
		return text
	}))
}


### Dataview Version

0.5.19

### Obsidian Version

0.14.6

### OS

MacOS

imeed166 avatar May 09 '22 21:05 imeed166

  • I tried with a clean vault (only dataview enabled), same problem.
  • I used the latest stable release (0.4.26) and didn't have this problem.

imeed166 avatar May 09 '22 21:05 imeed166

How frequently did this refresh in 0.4.26 in comparison? What is the refresh interval set to in the settings?

blacksmithgu avatar May 10 '22 02:05 blacksmithgu

The refresh interval in stable and in beta is the default 250 milliseconds. In the stable version, it didn't refresh when writing in another pane.

imeed166 avatar May 10 '22 11:05 imeed166

For a simple fix for right now I recommend upping the refresh interval to 2500 or 5000; this doesn't fix the root problem, but will make it a little less annoying for you.

I'm not quite sure what changed between stable and beta to cause this behavior (the renderer is unchanged), but I think the correct fix is an improvement to the DataviewJS render API to eliminate the annoying refresh behavior in the first place.

blacksmithgu avatar May 14 '22 07:05 blacksmithgu

this is now fixed with the latest update (0.5.26) even when using 250 in refresh interval

imeed166 avatar Jun 05 '22 13:06 imeed166

Ah sorry, made a mistake, still same problem

imeed166 avatar Jun 05 '22 17:06 imeed166

Is there a way we can inject a bit of custom code to see/profile which bits are running continuously?

AB1908 avatar Jun 05 '22 18:06 AB1908

@AB1908 You're talking to blacksmithgu right ?

imeed166 avatar Jun 05 '22 18:06 imeed166

I have started to have a similar problem after upgrading to 0.5.25 - 0.5.26, in 0.4.26 it didn't happen.

Obsidian: v0.14.15 (installer 0.14.6) macOS Monterrey Theme: Minimal 5.2.10 but with the default theme also happens.

punxsutawney avatar Jun 06 '22 12:06 punxsutawney

I think recent performance improvements should make the flickering much less apparent in DataviewJS rendering; it may still flicker but should render nearly instantly. The dv.page() API was much slower than it should have been which could cause lag.

blacksmithgu avatar Jun 07 '22 06:06 blacksmithgu

Making it truly "flickerless" requires a different way to render DataviewJS views which I need to think about more, using React.

blacksmithgu avatar Jun 07 '22 06:06 blacksmithgu

Understood, thank you. If I can do anything to help you with the problem, please let me know. I would love to help to go back to 0.4.26 flickerless perfection :-) BTW. Thank you for this fantastic plugin!

punxsutawney avatar Jun 09 '22 15:06 punxsutawney

If you have time, can you take a performance profile (using developer tools > Performance) of you typing and the view flickering? It would help to figure out what is being slow.

blacksmithgu avatar Jun 09 '22 21:06 blacksmithgu

Hope it helps! Profile-20220611T201913.json.zip

punxsutawney avatar Jun 11 '22 18:06 punxsutawney

First of all, thanks so much for making such an incredible plugin! It was a big part of the reason that I switched from Roam, and I really appreciate all the time you've put into it.

I just want to say that unfortunately, this is also a problem for me.

It wouldn't be that big of a deal, except my daily note is relatively long and it has two dataview queries at the top. When they flicker (basically continuously at every refresh interval if I'm typing), it causes the editor to move and the text to either move or sometimes go totally out of view. This obviously is quite distracting and makes it hard to write / focus. I have increased the refresh interval, and that helped, but it still happens often enough to be quite disruptive.

Anyway, I'm sure I can do a workaround (fold it or put the query at the bottom or something), but nonetheless, anything to fix this would be greatly appreciated!

danrthompson avatar Oct 05 '22 20:10 danrthompson

How about making it update (flicker) only when there's a change in the output?

charleshan avatar Dec 24 '22 07:12 charleshan

I turned off Automatic View Refreshing because of the continuous flickering but that created another problem: Dataview: No results to show for table query. on startup when used with CustomJs plugin. I won't create another issue for that because I'd much rather have this fixed if possible.


Edit: I realized another reason why I turned off Automatic View Refreshing: Inline embedding Dataview queries.

charleshan avatar Feb 10 '23 07:02 charleshan

@charleshan I did find a solution to this. I turned off automatic view refreshing, and then I assigned a keyboard shortcut (option-R) to refresh dataview queries. So now, when I open a file that has a query, I just immediately run the shortcut. Ditto if I want to see updated content. That way there isn't flickering, but it's super easy to get the results quickly.

danrthompson avatar Feb 28 '23 00:02 danrthompson

@danrthompson Do you mean Dataview: Force Refresh All Views and Blocks? I tried that but that doesn't do anything for me

charleshan avatar Feb 28 '23 03:02 charleshan

@charleshan yes that's what I'm referring to. It definitely works for me. Are you positive that your query works? Maybe try writing a very simple dataview query that queries the file modified time or something like that, or even a dataview JS query that queries the current time. Once you write the query, when you move your cursor outside of the code block, it should update with the results even if the update interval is turned off. If it's showing something, then you know it's working. If it's not showing anything, then I believe that's an issue with the query, not with the refresh command. Then try the force refresh to see if it works and the value updates.

I don't mean this to be patronizing if you've already thoroughly debugged it. Just suggesting that if there's a chance that your query might be the problem, it might be easy to think that the force refresh doesn't work, when in fact, the query's just not returning anything.

By the way, you could also try setting the dataview, refresh interval to the highest possible value other than never. I'm not sure whether my interval is actually set to never, vs just a very high interval, so there's a small chance that maybe that is playing a role. If you set it to whatever the max is, it should probably prevent flickering. If that enables the force refresh Command to work, I guess that was the problem.

If neither of those solutions work, try updating the plug-in if one is available?

And then, finally, if none of that works, you could have interference from another plug-in. I've had that happen before. Try turning off all your other plug-ins except for dataview and see if that fixes the problem. If it does solve it, then you just have to figure out what the offending plug-in is. If it doesn't, it sounds like there is a problem that you're having that I'm not having. Sorry about that.

Anyway, hope something here works. The force refresh command does work for me though, so at least there's some hope that you can get this to work. It's not actually a bad solution at all if you can get it to work. I actually prefer it even if it didn't flicker with a regular interval, because this way it doesn't slow things down at all, and it's not like I need to update the query views very often. So the command is a great solution actually.

Finally, if you make a query that is not returning results at all, even after writing it and moving your cursor out of the query, and you're pretty sure that it's correct but not positive, you can just send me your query, and I'm happy to take a look at it. I'm very familiar with dataview and I've used it a lot, so I should be able to help you debug it. I'm familiar with dataview JS as well as regular dataview. I'm heading on a trip in the next couple days so if I don't get back to you for a while, that's why, but if you send it to me tomorrow, I'll try to take a look. But I would start with a query that's extremely simple. Like two lines or something. Just a line of JavaScript to grab the current time and then a DV list to display it. Keep it as simple as possible when debugging so that you're positive the query itself is not the issue.

danrthompson avatar Feb 28 '23 05:02 danrthompson

@danrthompson thanks a lot for the help here. I had a tangential request if you didn't mind. That's a pretty good list of troubleshooting steps we could add to the FAQ/readme so I'd really appreciate if you could PR them in.

AB1908 avatar Feb 28 '23 08:02 AB1908

@AB1908 no problem. I use the plugin all the time, so I thought I'd try to help :).

I'd be happy to do that, especially if you don't mind me not making too many changes. You are of course welcome to rewrite it however you want.

Which comments/parts of the advice would you like me to submit?

You could see my comments as being either two separate pieces advice, or as one. Basically, I explain how you could set the refresh duration to never (or technically mine is set to every 83 minutes or 5 million milliseconds 😄) and use force refresh when you want to refresh.

Then I explain how to debug if it isn't working.

So you could see that as one piece of advice and how to debug if not working, or you could see it as how to fix flashing and then how to debug.

I'm happy to make a PR with both thoughts combined, separate, or just one or the other. Whatever is most useful for you.

danrthompson avatar Feb 28 '23 19:02 danrthompson

@danrthompson Do you mean Dataview: Force Refresh All Views and Blocks? I tried that but that doesn't do anything for me

Force Refresh has a bug: https://github.com/blacksmithgu/obsidian-dataview/issues/1752

ces3001 avatar Mar 02 '23 23:03 ces3001

@ces3001 weird… I do mean that and it works for me. I wonder if it's sporadically working, or only fails under certain circumstances? I just confirmed that it does definitely work for me, and I am on the latest Obsidian version (v1.1.16, installer version v0.14.15 - note that I am a contributor so I have access to insider Obsidian builds), and the latest dataview version (v0.5.55).

danrthompson avatar Mar 25 '23 22:03 danrthompson