Avoid app_handler Extra Jump to C++#52
Merged
doctorlai-msrc merged 23 commits intomainfrom May 13, 2025
Merged
Conversation
matthewbalkwill
requested changes
May 12, 2025
| class AppStateVars(ctypes.Structure): | ||
| _fields_ = [ | ||
| ("app", ctypes.POINTER(JrtcApp)), | ||
| ("app", ctypes.py_object), |
Collaborator
There was a problem hiding this comment.
I dont think the python apps should now have any references to ctypes, since this should now be python only
Collaborator
Author
There was a problem hiding this comment.
You can't have Python type here as AppStateVars is ctypes.Structures. Otherwise, this have to be moved out somewhere.
Collaborator
There was a problem hiding this comment.
but this doesnt need to be a ctypes.Strucutre does it ? It can be a simple Python dataclass, or even a dict
src/wrapper_apis/python/jrtc_app.py
Outdated
| lib.jrtc_app_router_channel_send_output_msg.argtypes = [ctypes.POINTER(JrtcApp), c_int, c_void_p, c_int] | ||
| lib.jrtc_app_router_channel_send_output_msg.restype = c_int | ||
| # Callback type definition | ||
| JrtcAppHandler = ctypes.CFUNCTYPE( |
Collaborator
There was a problem hiding this comment.
As pre my previous comment, do we need any ctypes stuff here ? I think we just want to pass python varables
matthewbalkwill
approved these changes
May 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes #51
The current implementation of the
app_handlercallback in Python apps contains unnecessary code that is causing performance issues and random Python crashes. This was done this way because we wanted to reuse the C++ codejrtc_app.cppThe call chain is:
In the
app_handler()function (user's code), the following (memory allocation) will crash the JRTC randomly:This may be due to the memory allocation where the lists are allocated in the stack intead of the heap.
This PR implements the
jrtc_app.cppin Python, so the unnecessary hop to C++ space is eliminated. Thejrtc_app.pywill now be in Python instead of wrapping C++ code.With this PR, the python app won't randomly crash for above Python code.