Skip to content

Fix webview testapp jnius usage#2597

Merged
AndreMiras merged 2 commits intokivy:developfrom
dbnicholson:webview-testapp-jnius
May 20, 2022
Merged

Fix webview testapp jnius usage#2597
AndreMiras merged 2 commits intokivy:developfrom
dbnicholson:webview-testapp-jnius

Conversation

@dbnicholson
Copy link
Contributor

Disable flask threading so that jnius works using the webview bootstrap. See #2533 for more details.

Current Flask throws an exception if a view function returns `None`:

```
python  : TypeError: The view function for 'vibrate' did not return a
valid response. The function either returned None or ended without a
return statement.
```

Maybe that was different in the past, but instead a proper response can
be returned. An empty 200 would be fine, but a 204 No Content response
is used since it better represents what's happening.
When flask is run in threaded mode, it creates a new thread to handle
each response. In that case, Java classes found with jnius will use the
system class loader instead of the app class loader since the new thread
has no stack frame back to the app. Normally you'd resolve the classes
first, but the test app is explicitly trying to delay loading the
classes until needed. That won't work from new native threads.
Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@AndreMiras AndreMiras merged commit eeea8a1 into kivy:develop May 20, 2022
@dbnicholson dbnicholson deleted the webview-testapp-jnius branch May 20, 2022 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants