I thought that was a possibility at first, it may have something to do with it, but given the data in my last post, the large gaps in between receiving the handleAsyncUpdate() callback seem to be the issue here.
So I created a third project, available here, where I combined the last two examples:
CodeEditorTest3.zip (15.0 KB)
void MainComponent::hiResTimerCallback()
{
juce::String messageText = getTimeStamp() + " - " + juce::String(count++);
// add the message string to the list of messages that need to be posted asynchronously
// and trigger a call to AsyncUpdate
{
const juce::ScopedLock sl (messageListLock);
messageList.add(messageText);
triggerAsyncUpdate(); // all examples have this inside the lock, I don't know why
}
}
juce::String MainComponent::getTimeStamp()
{
double hiResTime = juce::Time::getMillisecondCounterHiRes();
long inSeconds = (long) (hiResTime * .001);
auto hours = ((int) (inSeconds / 3600)) % 24;
auto minutes = ((int) (inSeconds / 60)) % 60;
auto seconds = ((int) inSeconds) % 60;
auto millis = ((int) (hiResTime) % 1000);
auto micros = ((long long) (hiResTime * 1000) % 1000); // can be out of range for int
return juce::String::formatted("%02d:%02d:%02d.%03d %03lld",
hours, minutes, seconds, millis, micros );
}
void MainComponent::handleAsyncUpdate()
{
// here we create an empty string array
// lock the messageList and swap it with the empty one
// therefore we empty the main list and now have a local copy of it
// the lock prevents it from being altered while we are swapping it
juce::StringArray messages;
{
const juce::ScopedLock sl (messageListLock);
messages.swapWith (messageList);
}
// assemble a chunk of text containing strings followed by line returns
juce::String messageText;
for (auto& string : messages)
messageText << string << "\n";
// add a timestamp indicating this function was called
messageText << getTimeStamp() << " handleAsyncUpdate\n";
// add the text or text chunk to the end of the messageDisplay
messageDisplay->moveCaretToEnd(false);
messageDisplay->insertTextAtCaret (messageText);
}
I made the message being posted every 1 ms much less text (just the timestamp and the count), and then there is a message added to the list when the handleAsyncUpdate() callback is actually received.
The JUCE 7 version shows that the handleAsyncUpdate() is received nearly every ms, so nearly each message is able to be appended individually, so the scrolling of the list in real-time is smooth:
JUCE 7.0.12
00:19:56.017 653 - 0
00:19:56.017 736 handleAsyncUpdate
00:19:56.018 656 - 1
00:19:56.018 743 handleAsyncUpdate
00:19:56.019 656 - 2
00:19:56.019 744 handleAsyncUpdate
00:19:56.020 657 - 3
00:19:56.020 746 handleAsyncUpdate
00:19:56.021 663 - 4
00:19:56.021 752 handleAsyncUpdate
00:19:56.022 655 - 5
00:19:56.022 744 handleAsyncUpdate
00:19:56.023 634 - 6
00:19:56.024 628 - 7
00:19:56.024 938 handleAsyncUpdate
00:19:56.025 653 - 8
00:19:56.025 738 handleAsyncUpdate
00:19:56.026 643 - 9
00:19:56.026 725 handleAsyncUpdate
00:19:56.027 633 - 10
00:19:56.027 690 handleAsyncUpdate
00:19:56.028 645 - 11
00:19:56.028 701 handleAsyncUpdate
00:19:56.029 650 - 12
00:19:56.029 707 handleAsyncUpdate
00:19:56.030 649 - 13
00:19:56.030 705 handleAsyncUpdate
00:19:56.031 644 - 14
00:19:56.031 704 handleAsyncUpdate
00:19:56.032 631 - 15
00:19:56.032 730 handleAsyncUpdate
00:19:56.033 654 - 16
00:19:56.033 736 handleAsyncUpdate
00:19:56.034 658 - 17
00:19:56.034 741 handleAsyncUpdate
00:19:56.035 656 - 18
00:19:56.035 738 handleAsyncUpdate
00:19:56.036 647 - 19
00:19:56.036 703 handleAsyncUpdate
00:19:56.037 642 - 20
00:19:56.037 697 handleAsyncUpdate
00:19:56.038 657 - 21
00:19:56.038 713 handleAsyncUpdate
00:19:56.039 637 - 22
00:19:56.039 694 handleAsyncUpdate
The JUCE 8 version shows that there are a few callbacks received 1 ms apart, and then large gaps of time where nothing is received and a large number of messages accumulate.
JUCE 8.0.3
21:38:31.358 930 - 0
21:38:31.359 036 handleAsyncUpdate
21:38:31.359 931 - 1
21:38:31.360 008 handleAsyncUpdate
21:38:31.360 924 - 2
21:38:31.361 003 handleAsyncUpdate
21:38:31.361 924 - 3
21:38:31.362 926 - 4
21:38:31.363 929 - 5
21:38:31.364 929 - 6
21:38:31.365 928 - 7
21:38:31.366 923 - 8
21:38:31.367 924 - 9
21:38:31.368 925 - 10
21:38:31.369 927 - 11
21:38:31.370 924 - 12
21:38:31.371 919 - 13
21:38:31.372 921 - 14
21:38:31.373 922 - 15
21:38:31.374 920 - 16
21:38:31.375 922 - 17
21:38:31.376 921 - 18
21:38:31.377 924 - 19
21:38:31.378 920 - 20
21:38:31.379 926 - 21
21:38:31.380 887 handleAsyncUpdate
21:38:31.380 925 - 22
21:38:31.381 096 handleAsyncUpdate
21:38:31.381 919 - 23
21:38:31.381 990 handleAsyncUpdate
21:38:31.382 918 - 24
21:38:31.382 975 handleAsyncUpdate
21:38:31.383 922 - 25
21:38:31.383 992 handleAsyncUpdate
21:38:31.384 925 - 26
21:38:31.384 997 handleAsyncUpdate
21:38:31.385 917 - 27
21:38:31.385 975 handleAsyncUpdate
21:38:31.386 918 - 28
21:38:31.386 983 handleAsyncUpdate
21:38:31.387 920 - 29
21:38:31.387 977 handleAsyncUpdate
21:38:31.388 921 - 30
21:38:31.389 920 - 31
21:38:31.390 133 handleAsyncUpdate
21:38:31.390 921 - 32
21:38:31.390 989 handleAsyncUpdate
21:38:31.391 921 - 33
21:38:31.391 995 handleAsyncUpdate
21:38:31.392 917 - 34
21:38:31.392 969 handleAsyncUpdate
21:38:31.393 919 - 35
21:38:31.393 984 handleAsyncUpdate
21:38:31.394 927 - 36
21:38:31.395 921 - 37
21:38:31.396 919 - 38
21:38:31.397 922 - 39
21:38:31.398 921 - 40
21:38:31.399 924 - 41
21:38:31.400 921 - 42
21:38:31.401 921 - 43
21:38:31.402 920 - 44
21:38:31.403 921 - 45
21:38:31.404 924 - 46
21:38:31.405 919 - 47
21:38:31.406 923 - 48
21:38:31.407 923 - 49
21:38:31.408 922 - 50
21:38:31.409 922 - 51
21:38:31.410 920 - 52
21:38:31.411 922 - 53
21:38:31.412 924 - 54
21:38:31.413 923 - 55
21:38:31.414 925 - 56
21:38:31.415 920 - 57
21:38:31.416 921 - 58
21:38:31.417 919 - 59
21:38:31.418 921 - 60
21:38:31.419 922 - 61
21:38:31.420 923 - 62
21:38:31.421 923 - 63
21:38:31.422 926 - 64
21:38:31.423 924 - 65
21:38:31.424 921 - 66
21:38:31.425 924 - 67
21:38:31.426 925 - 68
21:38:31.427 925 - 69
21:38:31.428 926 - 70
21:38:31.429 916 - 71
21:38:31.430 914 - 72
21:38:31.431 916 - 73
21:38:31.432 921 - 74
21:38:31.433 925 - 75
21:38:31.434 925 - 76
21:38:31.435 924 - 77
21:38:31.436 921 - 78
21:38:31.437 917 - 79
21:38:31.438 921 - 80
21:38:31.439 924 - 81
21:38:31.440 925 - 82
21:38:31.441 923 - 83
21:38:31.442 919 - 84
21:38:31.443 918 - 85
21:38:31.444 927 - 86
21:38:31.445 928 - 87
21:38:31.446 926 - 88
21:38:31.447 921 - 89
21:38:31.448 922 - 90
21:38:31.449 930 - 91
21:38:31.450 920 - 92
21:38:31.451 923 - 93
21:38:31.452 923 - 94
21:38:31.453 926 - 95
21:38:31.454 925 - 96
21:38:31.455 923 - 97
21:38:31.456 921 - 98
21:38:31.457 923 - 99
21:38:31.458 927 - 100
21:38:31.459 921 - 101
21:38:31.460 922 - 102
21:38:31.461 924 - 103
21:38:31.462 922 - 104
21:38:31.463 928 - 105
21:38:31.464 920 - 106
21:38:31.465 920 - 107
21:38:31.466 922 - 108
21:38:31.467 923 - 109
21:38:31.468 925 - 110
21:38:31.469 922 - 111
21:38:31.470 923 - 112
21:38:31.471 918 - 113
21:38:31.472 921 - 114
21:38:31.473 921 - 115
21:38:31.474 923 - 116
21:38:31.475 922 - 117
21:38:31.476 924 - 118
21:38:31.477 926 - 119
21:38:31.478 923 - 120
21:38:31.479 919 - 121
21:38:31.480 921 - 122
21:38:31.481 928 - 123
21:38:31.482 093 handleAsyncUpdate
21:38:31.482 923 - 124
Then the whole chunk of accumulated messages gets inserted at one time, causing the jerky and halting updating seen in video at the top.
So with JUCE 8, there are large interruptions in receiving the handleAsyncUpdate() callback.