-
-
Notifications
You must be signed in to change notification settings - Fork 228
feat: Improve onyxsdk-pen integration #1452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1452 +/- ##
==========================================
+ Coverage 47.99% 48.13% +0.13%
==========================================
Files 118 118
Lines 8723 8746 +23
==========================================
+ Hits 4187 4210 +23
Misses 4536 4536 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi, On my NoteAir 2 there is a huge lag (approx. 30s) after I lift my pen and before the actual stroke is rendered from scribble. I tried to fix this issue and came up with this solution (same for eraser): override fun onBeginRawDrawing(b: Boolean, touchPoint: TouchPoint) {
// begin of stylus data
touchHelper.setRawDrawingRenderEnabled(true)
reset()
}
override fun onEndRawDrawing(b: Boolean, touchPoint: TouchPoint) {
// end of stylus data
touchHelper.setRawDrawingRenderEnabled(false)
reset()
scheduleRefresh()
} With such toggling the lag disappeared and expirience became closer to proprietary note app. Also there is an issue with releasing resources of |
Regarding this lag, this should be handled in
Can reproduce, override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
if (call.method == "updateStroke") {
val params = call.arguments<Map<String, Any>?>()
updateStroke(params)
result.success(null)
} else if (call.method == "disableDraw") {
touchHelper.setRawDrawingEnabled(false)
} else if (call.method == "enableDraw") {
touchHelper.setRawDrawingEnabled(true)
} else {
result.notImplemented()
}
} |
In such way overriding @override
void dispose() {
channel.invokeMethod('disableDraw', creationParams).catchError((e) {});
} I'm not sure if it doesn't break anything in onyxsdk package interface. |
I am unable to compile and test, but did you encounter #1459 before the fix? |
Kinda, in some circumstances, not really sure, might just be my writing. If it is there, it will probably still be there, I did not mess with the code that gets the stylus data that's used after the refresh. I however can not test anything before 800e450, stuff just straight up does not work for me until that (I have a note air 4c, which is probably too new for version used before that) |
The most obvious strange thing is that, the top dot in "i" is thickened into a bullet. It does not look like this in the preview, but becomes this after a refresh. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Actually, your patch seems to fix #1459. At least, it is much better. To clarify, it is not fixed by only upgrading onyxsdk as in 800e450. It is unclear why this patch fixes the issue. Thank you very much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really impressive, thank you! Just requesting some tiny changes
enum class StrokeStyle(val Id: Int) { | ||
FountainPen(0), | ||
Pen(1), | ||
Brush(2), | ||
Pencil(3), | ||
Marker(4) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should define this enum in the dart package too as OnyxStrokeStyle
lib/components/canvas/canvas.dart
Outdated
int toolToOnyx(Tool currentTool) { | ||
if (placeholder) return 5; | ||
if (currentTool is Pencil) { | ||
return 3; | ||
} else if (currentTool is Highlighter) { | ||
return 4; | ||
} else if (currentTool is Eraser) { | ||
return 1; | ||
} else if (currentTool is Select) { | ||
return 1; | ||
} else if (currentTool is LaserPointer) { | ||
return 1; | ||
} else if (currentTool is Pen) { | ||
if (currentTool.isPressureEnabled()) { | ||
return 2; | ||
} else { | ||
return 1; | ||
} | ||
} else { | ||
return 5; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can then use the enum's values instead of ints
lib/components/canvas/canvas.dart
Outdated
int getColor() { | ||
if (currentTool is Pen) { | ||
return (currentTool as Pen).color.toARGB32(); | ||
} else { | ||
return Colors.black.toARGB32(); | ||
} | ||
} | ||
double getWidth() { | ||
if (currentTool is Pen) { | ||
double baseSize = (currentTool as Pen).getSize() * currentScale; | ||
if ((currentTool as Pen).isPressureEnabled()) { | ||
return baseSize; | ||
} else { | ||
return baseSize * 2; | ||
} | ||
} else { | ||
return 3; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these methods would be best named getOnyxTool
, getOnyxColor
, getOnyxWidth
so their purpose is more clear
lib/data/tools/pen.dart
Outdated
bool isPressureEnabled() { | ||
return pressureEnabled; | ||
} | ||
double getSize() { | ||
return options.size; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These seem like redundant getters, we can just use the underlying fields themselves
packages/onyxsdk_pen/android/src/main/kotlin/com/example/onyxsdk_pen/OnyxsdkPenArea.kt
Show resolved
Hide resolved
/// is still writing, which will make the screen get stuck in a half-drawn | ||
/// state. | ||
final Duration refreshDelay; | ||
final int strokeStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an enum arg too like in kotlin: e.g. strokeStyle: OnyxStrokeStyle.fountainPen
I hope that somebody could take up to improve this patch. |
hey there -- it sounds like this Onyx SDK work is more or less complete but hasn't been merged yet? or am I missing something? |
There are some comments above on coding. I suspect that these improvements of coding could be done by AI. I do not know how to do that though. |
has anyone else noticed that when you include this stuff it breaks the Text control? |
Sorry I've been out of touch, been busy with lots of stuff. I'll try looking into all the stuff soon |
This is a bit janky, and sometimes fails to disable the overlay if user is fast enough. However, in situations where it does correctly work, it's a nice QoL, and when it doesn't, nothing actually breaks
Okay, seems like dart code is more tolerable now. While I was at it, I also made a small "feature" in the overlay to be able to select "disabled" tool from dart, which should make some stuff like erasing and editing text a bit more tolerable.
With 5911175 editing text is better. Typing on keyboard with a stylus however still initiates immediate draw, which blocks the screen refresh. At 2AM today I'm out of ideas both with how it is possible and how to fix that besides disabling the overlay altogether in those cases. With small batch of |
I've been hacking on it with Claude Code; I may have him take a crack at
fixing this tonight as well. Really appreciate you diving back into this,
man.
…On Sun, Jul 27, 2025, 6:03 PM Антон Климанов ***@***.***> wrote:
*zinstack625* left a comment (saber-notes/saber#1452)
<#1452 (comment)>
Okay, seems like dart code is more tolerable now. While I was at it, I
also made a small "feature" in the overlay to be able to select "disabled"
tool from dart, which *should* make some stuff like erasing and editing
text a bit more tolerable.
has anyone else noticed that when you include this stuff it breaks the
Text control?
With 5911175
<5911175>
editing text is better. Typing on keyboard with a stylus however still
initiates immediate draw, which blocks the screen refresh. At 2AM today I'm
out of ideas both with how it is possible and how to fix that besides
disabling the overlay altogether in those cases.
With small batch of hopelessly banging the head against the table
experiments all I could do is break stuff. I'll try throwing some more
stuff at a wall in the general area of
https://github.com/zinstack625/saber/blob/main/packages/onyxsdk_pen/android/src/main/kotlin/com/example/onyxsdk_pen/OnyxsdkPenArea.kt#L125
this week and maybe something will happen...
—
Reply to this email directly, view it on GitHub
<#1452 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEW5VXRZ4FFJQVLU7TA7Y33KVLC5AVCNFSM6AAAAABZMB7TR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCMRUG43TQNZRGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
did you fix this? I just built and ran it on my Tab Ultra C Pro and it seems fine -- I can get in and out of the text tool without it crashing or losing the Onyx SDK support -- with the exception of very quick strokes sometimes resulting in big filled circle "bubbles" -- especially things like the middle stroke of a capital H. it seems to be a worse problem right after you open or create a note. also -- can you explain why it still first draws according to how your pen writes and then after a delay seems to re-render using some other visualization library? is it not possible to just keep the first set of strokes? I feel like Flutter is doing something unwanted of its own accord here but I don't know enough yet to diagnose what it is. I also wonder if there's maybe a good reason to have a toggle in the settings menu to turn Onyx support on and off, even just from a code path separation point of view. |
Updated onyxsdk dependencies
Makes stuff work on some newer devices. Don't really know why, but before that, stylus input resulted in full refreshes, as if there were no support for that altogether. This was observed both on Play Store and on local builds. May, but should not break other devices support
Reworked OnyxsdkPenArea.kt
Much of the stuff done in
drawPreview
had absolutely no effects. Whole magic seems to happen inTouchHelper
. Removing that manual drawing, again, may break stuff on other devices, but most of the logic remained nonetheless. In case of breakages, should be trivial to bring that stuff back, or, if my intuition is correct, further simplify this class. Would really like to hear some feedback on that removed code if possibleOnyxsdkPenArea
and DartIn order to modify state of the PlatformView, message passing was required. It is used to update stroke parameters from Flutter UI toolbar to the PlatformView. I see the use as "refreshing" the
creationParams
. Might be useful in the future, both in of itself and as a precedent for other usecasesThis in effect resulted in directly-refreshed preview looking very similar to the underlying image. Most of the tools are practically indistinguishable and are only insignificantly changed in shape (underlying image is less detailed) and, in some cases significantly in color during full refresh (seen on attached video). Exception being the pencil (seen on attached video), but it's still pretty close. Don't think it can get closer without some legally questionable voodoo magic with onyxsdk
Dart side
Most are due to preparation of tool parameters to Kotlin side, some are due to canvas being unaware of the tool being used. I tried to make significant changes as close to the actual use as possible, but may have introduced a couple of unnecessary abstractions and translations along the way. Could possibly be done better, but I'm inexperienced in Flutter and Dart. Hopefully the changes are not disruptive
Seems to be doing good on Note Air 4C, but would be good if someone could test on other devices. This does not seem to introduce any slowdowns, does not touch any significant logic and does not introduce any UI changes
20250320.webm
Great project BTW